Monday, 20 June 2016

How to create comma separated values (CSV) in SQL server ?

Sometimes there will be a requirement to show the values in comma separated format in SQL server.
We can do it in many ways. Some of them are below.

Example: 

In the below example i am going to separate the first name column of person table with comma.



In the 1st method I used substring function to get the CSV.



In 2nd method i used ISNULL AND COALESCE function to get the result.


No comments:

Post a Comment