How to pass string parameter with `IN` operator in stored procedure SQL Server 2008

Here’s how I solved it: Working SQL Fiddle First I have create a function which splits the string value i.e. ‘1,2,4,5’ Split function: CREATE FUNCTION fn_Split(@text varchar(8000), @delimiter varchar(20) = ‘ ‘) RETURNS @Strings TABLE ( position int IDENTITY PRIMARY KEY, value varchar(8000) ) AS BEGIN DECLARE @index int SET @index = -1 WHILE (LEN(@text) … Read more