Empid Empname Salary
1 Ram 15000
2 Ramesh 20000
3 Ravi 25000
4 Sam 30000
5 Ganesh 35000
i want to display Empname in single cell separated with space.
i want the output as follows Empname in single cell
Ram Ramesh Ravi Sam Ganesh.
for that how to write the query in sql server.
1 Ram 15000
2 Ramesh 20000
3 Ravi 25000
4 Sam 30000
5 Ganesh 35000
i want to display Empname in single cell separated with space.
i want the output as follows Empname in single cell
Ram Ramesh Ravi Sam Ganesh.
for that how to write the query in sql server.

Abhinav AbhishekRank #2,198 · 642 reputationPosted May 15, 2017, 8:59 AM EDT
Dharmraj ThakurRank #577 · 4.2K reputationPosted May 15, 2017, 8:35 PM EDT
SELECT
STUFF(
(
SELECT ' '+ EmpName from Employee FOR XML PATH('')
),1,1,'') as Employees