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 |
|
anandc
Starting Member
20 Posts |
Posted - 2006-06-20 : 02:26:37
|
How do i include values in the IN clause dynamically.e.g.DECLARE @showAudit char(1)SET @showAudit = 'N'SELECT * FROM tr_CommTransWHERE Status IN (CASE WHEN @showAudit = 'N' THEN ('1','2','3') ELSE Status END)Can I write something like the above ??- Anand |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2006-06-20 : 02:38:42
|
| Check out sp_executeSQL and execute in SQL help files. RegardsSachinDon't sit back because of failure. It will come back to check if you still available. -- Binu |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-20 : 02:56:13
|
[code]DECLARE @showAudit char(1)SET @showAudit = 'N'SELECT * FROM tr_CommTransWHERE (@showAudit = 'N' and Status in ('1', '2', '3'))or @showAudit <> 'N'[/code] KH |
 |
|
|
miclare
Starting Member
5 Posts |
Posted - 2006-07-02 : 11:03:56
|
quote: Originally posted by anandc How do i include values in the IN clause dynamically.e.g.DECLARE @showAudit char(1)SET @showAudit = 'N'SELECT * FROM tr_CommTransWHERE Status IN (CASE WHEN @showAudit = 'N' THEN ('1','2','3') ELSE Status END)Can I write something like the above ??- Anand
i've got the same problem. any answer? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-03 : 02:37:44
|
| Did you try the method suggested by khtan?MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-03 : 02:43:36
|
"i've got the same problem. any answer?"What exactly is your problem ? Can you provide more information ? KH |
 |
|
|
|
|
|