Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 syntax error :(

Author  Topic 

mrm23
Posting Yak Master

198 Posts

Posted - 2010-04-22 : 09:16:56
Hi All,
I know this is silly but i am not able to correct it :(
i have a syntax error near '='.

DECLARE @Salutation SMALLINT
SET @Salutation = SELECT CASE WHEN @Gender = 0 THEN 1
WHEN @Gender = 1 THEN 2 ELSE 1 END

Please give me the correct syntax

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-22 : 09:18:48

DECLARE @Salutation SMALLINT
SET @Salutation = (SELECT CASE WHEN @Gender = 0 THEN 1
WHEN @Gender = 1 THEN 2 ELSE 1 END)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-22 : 09:19:41
or

DECLARE @Salutation SMALLINT
SET @Salutation = (SELECT CASE WHEN @Gender = 1 THEN 2 ELSE 1 END)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-22 : 09:20:19
SET @Salutation = CASE WHEN @Gender = 0 THEN 1
WHEN @Gender = 1 THEN 2 ELSE 1 END


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

mrm23
Posting Yak Master

198 Posts

Posted - 2010-04-22 : 09:21:31
Oops! it was indded a silly mistake! Sorry....
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-22 : 09:34:54
No problem
We all know situations like this.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -