Using Coalesce to Pivot.

Posted by Rajesh_Kumar under Sql Server category on | Points: 40 | Views : 731
If we want to pivot the data we could run the following command.
DECLARE @DepartmentName VARCHAR(1000)

SELECT @DepartmentName = COALESCE(@DepartmentName,'') + Department_Name + ',' 
FROM Department
WHERE Department_Name = 'Computers';

SELECT @DepartmentName AS DepartmentNames

And get the result set with comma separated in a single column.

Comments or Responses

Login to post response