sql - Multiple conditions for CONTAINS statement on a full-text indexed result set -


we have stored procedure takes in few parameters, 1 of these parameters has value , used filter result set. select statement contains multiple joins , long.

to avoid copy-pasting query multiple times, want able use if or case statement in where clause. problem is, using full-text index , contains statement, , i'm not quite sure how inject if or case statement inside/outside contains clause, this:

select * [query] where(     if @filter1 not null    begin     contains(somecolumn, @filter1)    end    else if @filter2 not null    begin     contains(anothercolumn, @filter2)    end) 

which doesn't work. can't put select query in view or function either because result set doesn't specify unique index key, i.e. cannot full-text indexed (right tables full-text indexed individually address issue).

so there way achieve this? potentially copy-pase long select query inside different if statement each filter, gets ugly. appreciated.

maybe i'm overlooking something, couldn't structure follows...

where ((@filter1 not null) , contains(..)) or ((@filter2 not null) , contains(..))

that's how similar scenario.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -