Convert the Rows value into CSV format

From this query you can convert row value into comma separated valuse

CREATE TABLE #tblTblValues (id int)
insert into #tblTblValues values (10)
insert into #tblTblValues values (20)
insert into #tblTblValues values (30)
insert into #tblTblValues values (40)
insert into #tblTblValues values (50)
insert into #tblTblValues values (60)
insert into #tblTblValues values (70)


DECLARE @Value varchar(2000)
SELECT @Value = COALESCE(@Value + ', ', '') + CAST(id AS varchar) FROM #tblTblValues
SELECT @Value
OutPut


10, 20, 30, 40, 50, 60, 70

No comments: