First the SQL language for MS SQL Server 2005 is called T-SQL,
Transact-SQL.  I think it's the same language for MS SQL Server 2008.
The best T-SQL book I've seen is: Inside Microsoft® SQL Server™ 2005 T-
SQL Querying by Itzik Ben-Gan - (Solid Quality Learning); Lubor
Kollar; Dejan Sarka.

On Nov 23, 4:38 pm, "Jon Liu" <[EMAIL PROTECTED]> wrote:
> I guess anyone who as a solid web reference or other reference material to
> creating stored procedures in MS SQL, it would be much
> appreciated...everything i found is for MySQL and Im finding a lot for the
> syntax is not the same.
>
> On Sun, Nov 23, 2008 at 2:26 PM, BigJ <[EMAIL PROTECTED]> wrote:
>
> > My procedure code:
>
> > ALTER PROCEDURE dbo.InsertImage
> >        (
> >       [EMAIL PROTECTED] varchar(50),
> >       [EMAIL PROTECTED] varchar(10),
> >       [EMAIL PROTECTED] int
> >        )
> > AS
> > BEGIN
> >        SELECT MAX(ImageCnt) AS MaxImageCnt FROM userImages
> >        WHERE ImagePath LIKE @ImagePath+'%'
>
> >         IF MaxImageCnt!=NULL
> >                SET @[EMAIL PROTECTED]
> >                SET @[EMAIL PROTECTED](MaxImageCnt AS varchar)
>
> >        INSERT UserImages (ImagePath,UserId,ImageCnt) VALUES
> > (@ImagePath,@UserId,@ImageCnt)
> > END
>
> > My question is how do you set a variable to the result of the SELECT
> > query, which should be in MaxImageCnt. When I try to save this, it
> > tells me that the compiler is basically trying to find a column caled
> > MaxImageCnt, which makes sense.  I guess this is a completely newie
> > syntactical issue, but i can't find anything on it.  i know there is
> > also other lopsided bad syntax in this procedure too, but please
> > ignore that and if possible provide insight to the problem i
> > asked...thanks guys.
>
> > Jon

Reply via email to