combine rows with single column--Query to combine multiple rows into one
DECLARE @str VARCHAR(100)
SELECT @str = COALESCE(@str + ',', '') + [ct]
FROM #cat1
Print @str
Here [ct] is column name that we have rows of data. Then finally entire rows of data is avilable in @str.
Example:
ct
--------
suresh
hemanth
kareem
malli
after processing with COALESCE then the output loks like.....
----------------------------------
suresh,hemanth,kareem,malli
No comments:
Post a Comment