• ajayvinay1979 (6/18/2013)


    Hi ,

    You can do as

    declare @table as table

    (id int)

    INSERT INTO @table

    SELECT 100 UNION ALL

    SELECT 101 UNION ALL

    SELECT 102 UNION ALL

    SELECT 103 UNION ALL

    SELECT 104

    declare @output as varchar(max)

    set @output='';

    select @output=@output+','+cast(id as VARchar) FROM @table t1

    select substring(@output,2,LEN(@output)-1) as Seq

    Good solution, but please note that this thread is more than 5 months old.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/