Together one column’s data in one string
11/01/2010 Leave a comment
There is a useful expression in T-SQL “COALESCE()” we can use it for combining a column data into a string easyly
For example
Declare @sumtextnvarchar(100)
select top 5 @sumtext = Coalesce(@sumtext + ‘;’ ,”) + Cast(Name as nvarchar)
from Country
print @sumtext
Output:
Afrika;Australi en Nieuw-Zeeland;Belgi;Benelux;Bulgarije;Canada;China;Duitsland;EU-landen;Frankrij
May the code be with you !