STUFF() Function in SQL Server, Comma separate string from Column in sql server

By 10th June 2019SQL

Here I have a table Emp and having a column Empid, and i want all these ids in comma seprate string than i can use stuff() method of sql through xml path.


SELECT STUFF((SELECT ',' + CAST(EmpId AS NVARCHAR(MAX))
					FROM tbl_EmpTable 
					FOR XML PATH('')), 1, 1, '') AS EmpIds