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 |
|
bill_
Starting Member
38 Posts |
Posted - 2011-03-14 : 17:18:59
|
| We have a parameter @stts that can have values 'Active','Closed','Both' and a field called stts that is char(25).We need to put this logic in a where clause right after the last "and"if (@stts='Active' and substring(stts,2,1)='') or (@stts='Closed' and substring(stts,2,1)<>'')then trueelse falseendHow is that done? |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-03-15 : 00:46:13
|
| Use CASE statement |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-03-15 : 00:49:52
|
| Something like:Declare @stts varchar(25)Select * from sys.objects where 1 = 1 and --Your last end statementCase When (@stts='Active' and substring(stts,2,1)='') or (@stts='Closed' and substring(stts,2,1)<>'') Then 1 Else 0 End = 0 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-03-15 : 10:32:20
|
| and((@stts='Active' and substring(stts,2,1)='') or (@stts='Closed' and substring(stts,2,1)<>''))MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|