Question: SQL query to get Column Values with comma(,) Separation
Answer Part-2:
Dear Reader, to see the answer, please watch video by clicking below Link,
ANSWER PART-1
ANSWER PART-2
Practice Query is:
-- table creation
create table TestQ4_1
(
ID int identity(1,1),
EmpName nvarchar(200)
)
Go
-- insert data
Insert into TestQ4_1 (EmpName) Values ('Emp-1'),('Emp-2'),('Emp-3'),('Emp-4'),('Emp-5')
Go
-- using coalesce (If don't want use XML PATH and STUFF)
declare @tt nvarchar(200)
select @tt=coalesce(@tt+',','')+CAST(EmpName AS nvarchar)
from TestQ4_1
select @tt
Feel free to mail me for any query or feedback.
Happy Coding.
Rudra Pratap Singh
Software Engineer
singhrudrapratap29@gmail.com
+91-9307474998 (whatsapp)
Answer Part-2:
Dear Reader, to see the answer, please watch video by clicking below Link,
ANSWER PART-1
ANSWER PART-2
Practice Query is:
-- table creation
create table TestQ4_1
(
ID int identity(1,1),
EmpName nvarchar(200)
)
Go
-- insert data
Insert into TestQ4_1 (EmpName) Values ('Emp-1'),('Emp-2'),('Emp-3'),('Emp-4'),('Emp-5')
Go
-- using coalesce (If don't want use XML PATH and STUFF)
declare @tt nvarchar(200)
select @tt=coalesce(@tt+',','')+CAST(EmpName AS nvarchar)
from TestQ4_1
select @tt
Feel free to mail me for any query or feedback.
Happy Coding.
Rudra Pratap Singh
Software Engineer
singhrudrapratap29@gmail.com
+91-9307474998 (whatsapp)