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 |
pushp82
Yak Posting Veteran
83 Posts |
Posted - 2013-01-31 : 01:17:25
|
Hi Guys,I'm jumbling around a "case syntax in where clause" from long time if someone could help me ASAP please....declare @Type intset @Type=1select * from tbl_outlet otleft join tbl_brand bn on bn.bnd_otl_id=ot.otl_idwhere case @Type when 1 then ot.OTL_NAME like '%A' endabove syntax is returning error, I tried all possible syntax but failed:Incorrect syntax near the keyword 'like'.Please advice!Pushp |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-31 : 01:24:23
|
case is not control flow statement. its just a conditional expressionso your condition have to bedeclare @Type intset @Type=1select * from tbl_outlet otleft join tbl_brand bn on bn.bnd_otl_id=ot.otl_idwhere ot.OTL_NAME like case @Type when 1 then '%A' end ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|