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 |
kirank
Yak Posting Veteran
58 Posts |
Posted - 2014-06-06 : 17:18:36
|
Hi,Just help me with below syntax, wanted to add condition on where clause that. SELECT * FROM RelationTbl WITH (NOLOCK) WHERE CASE WHEN Len(@variableName) = 14 THEN // this condition should work in where clause ELSE // another condition END I'm not sure how i can put the condition in then & else. basically will put value and base on case then or else get executed. Here i want to check if Len(@variableName) = 14 then REF = @variableName // this query execute ELSE REF = @variableName and NumType is null // this query execute Thanks, ---------------------------http://codingstuffsbykiran.blogspot.com | http://webdevlopementhelp.blogspot.com |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-06-06 : 17:22:16
|
WHERE (LEN(@variableName)=14 AND REF=@variableName) OR (REF=@variableName AND NumType IS NULL)Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
kirank
Yak Posting Veteran
58 Posts |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|