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 |
|
imp_galo
Starting Member
13 Posts |
Posted - 2005-12-20 : 06:57:46
|
| I've a C++ app in which the user can define custom filters. So there are a lot of fields he can select to filter or not.I've been using dynamic SQL and I just append the column name and the column value to the where clause. Is there any way I can use SP in this case? Is it preferable?thx in advance. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
imp_galo
Starting Member
13 Posts |
Posted - 2005-12-20 : 17:53:51
|
| Sorry madhivanan but I didn't quite get it. My problem is the following: I have a table named MyTable and the columns Cl1, Cl2, Cl3.According to the custom filters the user can choose, for example:1- select Data from MyTable where Cl1 = Value; or2- select Data from MyTable where Cl2 = Value; or3- select Data from MyTable where Cl3 = Value.Is there anyway I can fit it in a SP?thx again. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-12-20 : 18:23:53
|
| The trick to a dynamic WHERE clause without using dynamic SQL is to use COALESCE. Here is the SQLTeam article that explains this approach:http://www.sqlteam.com/item.asp?ItemID=2077Tara Kizeraka tduggan |
 |
|
|
|
|
|