Create comma separated string from table rows value
without using looping in SQL.
Or Create comma separated string from table rows values
using XQuery.
Using below query we can achieve it.
In above example created one temporary table #Test. In the #Test temp table inserted some string values.
Using the below query you can get comma separated string.
SELECT STUFF(( SELECT DISTINCT ',' + DataVal
FROM #Test
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') AS [Comma Separated String];
If you want to do reversely that mean to split comma separated value see in below link..
http://mastermindsdotnet.blogspot.in/2013/07/split-comma-separated-string-without.html
No comments:
Post a Comment