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.
| Author |
Topic |
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2007-01-23 : 09:25:00
|
| i am writing a stored procedure which uses case statment (not as a part of a select) and i want the result to put into a @val1how do i do that?thnaks i advancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-23 : 09:34:03
|
case statment (not as a part of a select)What do you mean by that?Select @val1 = Case When SomeCodition1 Then someValue1 When SomeCondition2 Then someValue2 ... EndFrom SomeTable Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2007-01-23 : 09:35:00
|
| [code]SELECT @val1 = CASE WHEN [FirstCondition] THEN [FirstValue] WHEN [SecondCondition] THEN [SecondValue] ... etc... ELSE [ElseValue] END[/code]Clearly, as this isn't inline, you could use IF/ELSEIF.Mark |
 |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2007-01-23 : 10:12:26
|
| thnaks mwjdavidsonthaty what i wantedbtw : i didnt see elsei codeIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2007-01-23 : 12:26:26
|
| No problem. Lookup "IF...ELSE" in BOL.Mark |
 |
|
|
|
|
|