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 |
|
pkuchaliya
Starting Member
49 Posts |
Posted - 2008-09-04 : 09:02:50
|
| hi frnd, I want to perform the multiple checking with case . i want to check the different condition with case . is it possible to perform the given selection condition without if statementif(@x)=1begin"sql statement"endif(@x)=2begin"sql statement"endif(@x)=3begin"sql statement"endpankaj |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-09-04 : 09:07:24
|
| Are you changing the WHERE clause based on the condition?MadhivananFailing to plan is Planning to fail |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-09-04 : 09:09:03
|
quote: Originally posted by pkuchaliya hi frnd, I want to perform the multiple checking with case . i want to check the different condition with case . is it possible to perform the given selection condition without if statementif(@x)=1begin"sql statement"endif(@x)=2begin"sql statement"endif(@x)=3begin"sql statement"endpankaj
declare @x intselect case when @x = 1 then 'Sql Stmt1' when @x= 2 then 'Sql Stmt2' when @x= 3 then 'Sql Stmt3' end |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-09-04 : 09:11:14
|
quote: Originally posted by raky
quote: Originally posted by pkuchaliya hi frnd, I want to perform the multiple checking with case . i want to check the different condition with case . is it possible to perform the given selection condition without if statementif(@x)=1begin"sql statement"endif(@x)=2begin"sql statement"endif(@x)=3begin"sql statement"endpankaj
declare @x intselect case when @x = 1 then 'Sql Stmt1' when @x= 2 then 'Sql Stmt2' when @x= 3 then 'Sql Stmt3' end
That wont work if the SELECT returns more than a valueMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|