---
title: "How to select comma separated list in Sqlserver"  
description: "How to select comma separated list in Sqlserver"  
author: "Anonymous User"  
published: 2015-12-25  
updated: 2015-12-25  
canonical: https://www.mindstick.com/forum/33788/how-to-select-comma-separated-list-in-sqlserver  
category: "database"  
tags: ["sql server", "sql", "sql server 2008", "sql server 2012"]  
reading_time: 1 minute  

---

# How to select comma separated list in Sqlserver

I want to [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) [comma separated](https://www.mindstick.com/forum/159360/how-to-write-sql-query-to-join-comma-separated-values) list in [Sql Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) please help me.

## Replies

### Reply by Anonymous User

When we want to generate a comma separated list of columns values like a list of EmailIDs to send mail. In [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) [Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over), 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.

```
declare @strEmailid Varchar(max);select @strEmailid=COALESCE(@strEmailid+',','')+ EmailID FROM EmployeePRINT @strEmailid
```

![How to select comma separated list in Sqlserver](https://www.mindstick.com/mindstickforums/a7aa30a4-2901-4266-acfe-bda8b1fc9121/images/72548341-473e-4838-91d1-6b02dffbea95.png)


---

Original Source: https://www.mindstick.com/forum/33788/how-to-select-comma-separated-list-in-sqlserver

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
