• Without seeing the dynamic_pivot procedure I can't give you the solution you probably want. I'm going to agree with Eddie.

    If the ID column is int you don't need to split the string. Try this:

    DECLARE @ids VARCHAR(100), @sql NVARCHAR(1000)

    SET @ids = '4,5,6'

    SET @sql = 'Select * from sys.objects as o where o.object_Id in (' + @ids + ')'

    EXEC (@sql)