SQL Server - Return Comma Separated Column Value

In SQL Server I have a table like below:

table

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

code

  1. SELECTSTUFF((SELECTDISTINCT', '+CAST(Name ASVARCHAR(100))  
  2. FROM Emp_Information FORXMLPATH('')),1,2,'')AS Employees  

 

Ebook Download
View all
SQL Jobs
Read by 0 people
Download Now!
Learn
View all