Showing posts with label SQL Server 2012. Show all posts
Showing posts with label SQL Server 2012. Show all posts

Friday, 1 February 2013

How to get all the Emails as Comma separatesd string in Sql Server.

SQL Server provides a function named Coalesce to do the task to join all the column value by comma separated string.

The Query is below:
Go
Declare @strEmail varchar(max)

SELECT @strEmail=coalesce(@strEmail+',','')+[Email]
       FROM Users      
print @strEmail