Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 17,578 of 19,505    |
|    Ed Murphy to Plamen Ratchev    |
|    Re: CASE Statement in WHERE EXISISTS Cla    |
|    20 Jul 09 21:12:36    |
      From: emurphy42@socal.rr.com              Plamen Ratchev wrote:              > You can do that with IF statement or dynamic SQL. The problem is even if       your predicate is formed correctly:       >       > WHERE (@KeywordString IS NULL OR FREETEXT(P.productname, @KeywordString))       > AND ...       >       > or       >       > WHERE CASE WHEN @KeywordString IS NULL       > THEN 'T'       > WHEN @KeywordString IS NOT NULL AND FREETEXT(P.productname,       @KeywordString)       > THEN 'T'       > ELSE 'F'       > END = 'T'       > AND ...       >       > You will get error "Null or empty full-text predicate." because the FREETEXT       predicate is always evaluated.       >       > To avoid this problem you can use IF:       >       > IF @KeywordString IS NOT NULL       > SELECT ...       > FROM ...       > WHERE FREETEXT(P.productname, @KeywordString)       > AND ...       > ELSE       > SELECT ...       > FROM ...       > WHERE ... |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca