Hi
You can use from bellow code:
Declare @ID nVarChar(500),
@Name nVarChar(500),
@Department nVarChar(500)
-------------------------------------------------------------------------------
Select @ID = N'',
@Name = N'',
@DepartMent = N''
------------------------------------------------------------------------------
Select @ID = @ID + ', ' + Cast(ID As VarChar),
@Name = @Name + ', ' + Name,
@Department = @Department + ', ' + Department
From [YourTableName]
-------------------------------------------------------------------------------
Select @ID = Substring(@ID, 2, Len(@ID)),
@Name = Substring(@Name, 2, Len(@Name)),
@Department = Substring(@Department, 2, Len(@Department))
-------------------------------------------------------------------------------
Select N'ID', @ID
Union
Select N'Name', @Name
Union
Select N'Department',@Department
If you want using this action dynamically, please tell me to write dynamic version for you.
I hope it's helpful