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 |
lfernandesfotos
Starting Member
2 Posts |
Posted - 2010-09-27 : 13:03:03
|
Hello!!!I have several procedures that uses in my point of view, WORST PRACTICES when filtering data. For exemple, to filter some status in the SQL we use to Concate Strings with the filteres:set @filterCustomer = @filterCustomer + ' and testUser = 0'The problem is that the query is all set in the variable @filterCustomer, generating a long string that will be called by an Exec command. This one is dificult to maintain, so there is another way on filtering data without using String Concate?===========Luiz Fernandeslfernandesfotos@hotmail.com |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-28 : 11:29:29
|
You can use this logicwhere(col=@col1 or @col1 is null)and(col=@col2 or @col2 is null)and.(col=@colN or @colN is null)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|