I have a table Details
DeptId EmpID
------- ---------
1 1
1 5
1 3
2 8
2 9
I want to group them like this:
DeptId EmpIDs
------- -------
1 1,5,3
2 8,9
I want this in SQL Server. I know this can be done in MySQL using Group_Concat
function. e.g.
SELECT DeptId, GROUP_CONCAT(EmpId SEPARATOR ',') EmpIDS
FROM Details GROUP BY DeptId
But how to do this with SQL Server? I don't know any function.