How to create the row data as string.
If you have table row data and you need to show all the records in a single string, use the following query.
DATA:
——————–
Name
RAM
SHYAM
HARI
RITA
RESULT:
———————
Name
RAM,SHYAM,HARI,RITA
Use the following query
————————————
DECLARE @strList varchar(100)
SELECT @strList = COALESCE(@strList + ‘, ‘, ”) +
CAST(Name AS varchar(5))
FROM TABLE1
SELECT @strList
There are complex example in internet but you can [...]
Filed under: Table Row in String | Tagged: COALESCE, How to create a row data as string., MSSQL tisp, MSSQL tricks, Multiple value in single String, SQL help, String creation | 1 Comment »









