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 |
mahesh423
Starting Member
9 Posts |
Posted - 2008-09-30 : 09:21:22
|
Hi i have a select query which actually differs depending upon the input parameters passed to the stored proc.i will pass a flag parameter which will have values either 1 or 0.the query isselect 1,2,3,4from Awhere A.state in (open,pending,waiting)if flag = 0the query must remain sameif flag =1then an additional state must get included i.e (settled)select 1,2,3,4from Awhere A.state in (open,pending,waiting.settled) i am thinkin a conditional stmt must work out...plz suggest me a better and efficient way to implement this..Mahesh Kumar |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-30 : 09:25:06
|
[code]SELECT 1, 2, 3, 4FROM aWHERE a.State IN ('open', 'pending', 'waiting') OR (@Flag = 1 AND a.State = 'settled')[/code] E 12°55'05.63"N 56°04'39.26" |
|
|
mahesh423
Starting Member
9 Posts |
Posted - 2008-09-30 : 22:28:09
|
Hi thanks for that smart query..tat will help me alot..Mahesh Kumar |
|
|
|
|
|
|
|