• Sarus-127369 (6/21/2011)


    too keep it simple whith less code (but only for short in-lists)

    Declare @inStr varchar(100)

    Set @inStr = '1,2,4,6'

    select * from testtable

    where ','+@inStr+',' like '%,'+cast(column as varchar)+',%'

    Saurus,

    I've used that type of LIKE before. Sometimes it works just fine, but it doesn't scale very well and the examples I used all had indexes on the column. The LIKE operator with '%' on the left won't use indexes.

    Todd Fifield