Ты это имел ввиду?
CREATE FUNCTION dbo.ParseString (@string varchar(500), @delimeter char(1))
RETURNS @valuelist table (
-- columns returned by the function
value nvarchar(255) NOT NULL
)
begin
declare @pos int
declare @piece varchar(500)
–- Need to tack a delimiter onto the end of the input string if one doesn’t exist
if right(rtrim(@string),1) <> @delimiter
set @string = @string + @delimiter
set @pos = patindex('%,%' , @string)
while @pos <> 0
begin
set @piece = left(@string, @pos – 1)
insert into @valuelist (value) VALUES (@piece)
set @string = stuff(@string, 1, @pos, '')
set @pos = patindex('%,%' , @string)
end
end
CREATE PROCEDURE usp_MySP
@ColValue1 varchar(100) = NULL
,@ColValue2 varchar(100) = NULL
AS
SELECT distinct Col1, Col2
FROM Table
inner join parsestring('a,b,c')
WHERE col1 like concat(value,'%');