How to use like'%%' with a parameter?
Posted on 2005-04-19
normally I use a like statement like this:
select * from table1 where field like '%something%'
Now I have a @parameter and I need to use a like statement but it seems to only work with strings. How can I get it to work with parameters? (I am testing it to be used in a stored procedure)
I am trying to write something like this:
declare @parameter varchar(100)
select @parameter = 'test string'
select * from table1 where field like '@parameter'
If it is not possible, is there another way this can be accomplished?
Any help is greatly appreciated.