Home Forums SQL Server 2008 T-SQL (SS2K8) how to retrieve the data when a comma separated ids are sent as input parameters RE: how to retrieve the data when a comma separated ids are sent as input parameters

  • One method would be a string splitter.

    Take a look in my signature for Jeff's string splitter and call it in your query

    declare @temp table(Userid int, forename varchar(200), surname varchar(200), locationid int)

    insert into @temp values (1,'ant','green',1),(2,'green','ant',2)

    declare @param varchar(10) = '1,2'

    SELECT

    UserID,

    Forename,

    Surname

    FROM

    @temp t

    INNER JOIN

    dbo.DelimitedSplit8K(@param,',') f

    on

    t.locationid = f.Item