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 |
|
cesark
Posting Yak Master
215 Posts |
Posted - 2005-09-29 : 12:50:34
|
Hi,I am writing a SP to filter user queries form web application, and thus return the record set according to received parameters. The user can filter the query with any of 20 parameters. The parameter I am dealing now is @Family_num, if its received value is ‘0’ then no filter is considered for family_num column, if its value is ‘9’ then the filter is other_families column different to null. And if its value is any other then filter by family_num column.How can I write this condition? Now I have this:WHERE Family_num = CASE WHEN @Family = 0 Then Family_num Else @Family End But this doesn’ t contemplate the case @Family = 9 described above (filter by other_families column different to null).How can I do it?Thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
cesark
Posting Yak Master
215 Posts |
Posted - 2005-09-30 : 11:33:15
|
I looked for somthig like this:WHERE ((Family_num = CASE WHEN @Family = 0 Then Family_num Else @Family End) OR (@Family = 9 AND other_families IS NOT NULL)) And... And.. And.. And.. Until now seems to work quite good |
 |
|
|
|
|
|