Introduction: Here we have to add all the rows of a column to string with comma seperated.
Description:I am going to use coalesce function of sql server to achieve the result.
Query:
DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ',', '') + Name
FROM tbl_Names
print @Names
Description:I am going to use coalesce function of sql server to achieve the result.
Query:
DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ',', '') + Name
FROM tbl_Names
print @Names
No comments:
Post a Comment