Query
SELECT Emp_FullName from Employees
My Select query reqult will be below
i want go get the result will be like given below as comma separated (Employee Name)
Ahmed Badr Fathel Saleh , Mohammed Saleh Alawi Al Rashidi
Query
SELECT Emp_FullName from Employees
My Select query reqult will be below
i want go get the result will be like given below as comma separated (Employee Name)
Ahmed Badr Fathel Saleh , Mohammed Saleh Alawi Al Rashidi
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rohini ParadePosted Apr 10, 2024, 2:45 PM
For SQL Server 2017 & Up version Use:
SELECT Stuff(
(
SELECT ', ' + CARS.CarName
FROM CARS
FOR XML PATH('')
), 1, 2, '') AS CarNames
For SQL Server 2016 & below :
SELECT LEFT(Car, LEN(Car) - 1)
FROM (
SELECT Car + ', '
FROM Cars
FOR XML PATH ('')
) c (Car)
Jaimin ShethiyaPosted Apr 9, 2024, 2:41 PM
Hello Lejo,
Please refer the below script and change the table name and field name as you want.
Thanks
Jayraj ChhayaPosted Apr 9, 2024, 1:59 PM
Hi,
You can use the
STRING_AGGfunction in SQL.Or you can use below code
Abhishek YadavPosted Apr 9, 2024, 10:32 AM
my friend it is not technically posible you need to irrate and mody the values using loops here is a C# example