Using COALESCE function - concatenate many rows into a single text string output in SQL Server.
The following code is used to concatenate many rows into a single text string with comma separated using SQL Server COALESCE function.(follwing two examples)
1. DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ', ', '') + Email FROM Emp_tb_eob_Employee where EmployeeID in(12,1)
SELECT @Names
2.
The following code is used to concatenate many rows into a single text string with comma separated using SQL Server COALESCE function.(follwing two examples)
1. DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ', ', '') + Email FROM Emp_tb_eob_Employee where EmployeeID in(12,1)
SELECT @Names
2.
Sign up here with your email
ConversionConversion EmoticonEmoticon