Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

SQL Server – Return Comma Separated column value

Article:
Viewed:  868 
Posted On:  4/1/2016 7:52:27 PM 
How we can return comma separated column value in SQL Server? 

 

In SQL Server I have a table like below:

1.png

Image 1.

Now I want to return Name Column value as comma separated using SQL Server statement:

 

2.png

Image 2.

 

SELECT STUFF((SELECT DISTINCT ', ' + CAST(Name AS VARCHAR(100))
FROM Emp_Information FOR XML PATH('')),1,2,'') AS Employees

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us