Concatenate many rows into a single text string using SQL Server
Using COALESCE function-
What is COALESCE function-
Concatenate many rows into a single text string with comma separated using SQL Server
My table format is like this:
(Select Name from Tbl_Customer)
Name
Jeet
Nitin
Pulkit
Rahul
Vibha
I need output like this:
Name
1. Jeet ,Nitin,Rahul,Pulkit,Vibha
Use This Code
DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ', ', '') + Name(ColumnName)
FROM Tbl_Customer
select @Names
Using COALESCE function-
What is COALESCE function-
Concatenate many rows into a single text string with comma separated using SQL Server
COALESCE
function.My table format is like this:
(Select Name from Tbl_Customer)
Name
Jeet
Nitin
Pulkit
Rahul
Vibha
I need output like this:
Name
1. Jeet ,Nitin,Rahul,Pulkit,Vibha
Use This Code
DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ', ', '') + Name(ColumnName)
FROM Tbl_Customer
select @Names
0 comments :
Post a Comment