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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-06-10 : 09:31:27
|
| Jochem writes "Hi,I am trying to build a stored procedures which has several changing where clause. A user can provide a bit value to specify whether or not closed items of a forum will be shown. By setting this bit to 1 a '>' should be used in the query, else a '<' should be used. I realize a can do this by building to queries and choose one of them, but I have 3 of these conditions in one stored procedure so that would mean a lot of deferent queries...So the concrete question is: Is there a way to turn the '>' sign in a where clause into a variable?I use a windows 2000 server with SQL server 2000" |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-06-10 : 09:46:22
|
there are many ways to do this, the easiest to understand would be something like ...where (column > othercolumn and bit = 1) or (column < othercolumn and bit = 0) <O> |
 |
|
|
Lady
Starting Member
32 Posts |
Posted - 2002-06-11 : 03:38:49
|
| why you didn't use Dynamic SQL? |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-06-11 : 04:29:51
|
| Avoid Dynamic Sql as much as possible coz it doesnt reuses the cache plan there by it isnt efficient( graz why dont you put this in FAQ) .-------------------------What lies behind you and what lies ahead of you are small matters compared to what lies within you.-Ralph Waldo Emerson |
 |
|
|
|
|
|