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 |
|
everlast88az
Starting Member
1 Post |
Posted - 2008-12-27 : 22:23:33
|
| I am trying to do a search into my data with four or so variables storing a string a user enters from a drop down box.I pass the values into a stored procedure, (its not important I just need the simple query)Then I want to test if each variable is null if not then go to the next variable in the stmt and test and so on. Then for each variable in the stmt that isnt null I want to do something like Select * FROM Table where Contains(Overview, @Word1) AND CONTAINS(Overview, @Word2) AND CONTAINS(Overview, @Word3)so I try like this.. which doesn't work...I also wanna check if the value is null in the case and then if it does turn out to be null do nothing and just go to the next case statement. I guess end accomplishes this? I am not sure as I am fairly new to SQL. THanks in advance,DECLARE@Word2 VARCHAR(15) = 'blah'@Word3 VARCHAR(15) = 'bladfsdh'SELECT * FROM Systems WHERE CASE @Word2 IS NOT NULL THEN CONTAINS(Overview, @Word2) ELSE --NOTHING END CASE @Word3 IS NOT NULL THEN CONTAINS(Overview, @Word3) ELSE -- NOTHING END |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|