fnCSVIDsToTable

Return

Return Type
table

Parameters

Parameter Parameter Type Mode Description
@sIDs varchar(8000) IN

Definition

Copy


        create function [dbo].[fnCSVIDsToTable]
        (
        @sIDs varchar(8000)
        )
        returns @IDs table (id int)
        as
        --select * from dbo.fn_ParseCSVString ('1,12,34')
        begin
        declare @i int
        declare @j int

        set @i = 1
        while @i <= len(@sIDs)
        begin
        select @j = charindex(',', @sIDs, @i)
        if @j = 0
        begin
        select @j = len(@sIDs) + 1
        end
        insert @IDs select substring(@sIDs, @i, @j - @i)
        select @i = @j + 1
        end
        return
        end