Please enable Javascript to correctly display the contents on Dot Net Tricks!

Create a comma separated list from column using select statement

  Author : Shailendra Chauhan
Updated On : 24 Sep 2016
Total Views : 129,406   
Support : SQL Server 2005,2008,2012
 

Sometimes we required to generate a comma separated list of columns values like a list of EmailIDs to send mail. In SQL Server, we can make a comma separated list by using COALESCE as shown in below.

Use of COALESCE to create comma separated list

Suppose we have following data in Employee table and we need to make a semicolon separated list of EmailIDs to send mail, then we can use COALESCE as shown in below fig.

Here I am creating a semicolon(;) separated list. You can use comma(,) in place of semicolon to make comma separated list.

For SQL Server database mail setup and configuration and more over how to send mail from SQL Server database you can refer this article.

Summary

In this article I expose the use of COALESCE to make comma separated or deli-meter separated list. I hope after reading this article you will be know how to configure SQL Database Mail in Sql Server. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.

YOU MIGHT LIKE
Free Interview Books
 
COMMENTS (0)
14 DEC
ASP.NET MVC with AngularJS Development (online)

MON-FRI 07:30 AM- 09:00 AM IST

Know More
5 DEC
AngularJS Development (online)

Mon - Fri     6:30 AM-7:30 AM IST

3 DEC
AngularJS Development (offline)

SAT,SUN     11:00 AM-12:30 PM IST

3 DEC
MEAN Stack Development (offline)

Sat, Sun     (09:30 AM-11:00 AM IST)

26 NOV
ASP.NET MVC with AngularJS Development (offline)

(SAT,SUN)     03:30 PM-05:00 PM IST

24 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     09:30 PM-11:00 PM IST

12 NOV
ASP.NET MVC with AngularJS Development (offline)

SAT,SUN     08:00 AM-09:30 AM

3 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     07:30 AM-09:00 AM IST

25 OCT
.NET Development (offline)

Mon-Fri     9:00 AM-11:00 AM IST

BROWSE BY CATEGORY
 
RECENT ARTICLES
SUBSCRIBE TO LATEST NEWS
 
LIKE US ON FACEBOOK
 

Professional Speaks

+