Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi All, I am trying to write a CASE statement depending on what is passed in the variable @vendor_type.Declare @vendor_type varchar(60)select @vendor_type = 'Keeltext'select product_id, order_id, case when @vendor_type ='Keeltext' then name_data like'%keel%' when @vendor_type ='Corell' then name_data like '%corell%'All help is appreciated. Thank you,Petronas
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2011-12-29 : 10:39:00
Would this work for you?
SELECT product_id, order_id, name_dataFROM yourTableWHERE name_data LIKE '%'+@vendor_type+'%';
quote:Originally posted by sunitabeck Would this work for you?
SELECT product_id, order_id, name_dataFROM yourTableWHERE name_data LIKE '%'+@vendor_type+'%';
Also..Doesn't using wildcards like this cause the engine to disregard indexes? I think you end up getting a full table scan in your query which could slow you down performance wise.