SQL query concatenate row value to string
We can do this in many ways , you can write SQL function , COALESCE , XML PATH.
So this time I'm give example using XML PATH and COALESCE. I use NORTHWND sample database to provide example
Example 1 : COALESCE (find more about COALESCE)
Using COALESCE function , we can concatenate many row values in to one single string. this is one use of COALESCE , there are many ,so you can find some more clicking above mention link.
1

2

In second example you can see I used STUFF function . So I used it for remove extra comma from string. Usually STUFF function does inserts a string into another string, it deletes first string character form begin for given length and put second string into it
No comments:
Post a Comment