As you found out, using it that way does not work. Instead, a quick solution would be to do the following:declare @pubID varchar(40) = '0736,1389,9901'select * from dbo.publisherswhere ','+@pubID+',' like '%,'+pub_id+',%'
That would work, but might not be the best from a performance perspective (because the presence of the '%,' would make it impossible for SQL to use any indexes you may have on pub_id column.Another possibility is to split the comma-separated string into a (virtual) table and join with that table. There are many string splitters that you can find if you google. One of my favorites is here: http://www.sqlservercentral.com/articles/Tally+Table/72993/ If you install the function in Fig.21 of that article, then you can do this:declare @pubID varchar(40) = '0736,1389,9901'select p.* from dbo.publishers pINNER JOIN dbo.DelimitedSplit8K(@pubID,',') s ON s.Item = t.pub_id
BTW, don't put a batch separator (GO statement) between your variable declaration and the rest of the code. The scope ends with the batch separator, so the variable will not be available in the select query if you do.