1DECLARE @UserMaster TABLE(
2
3 UserID INT NOT NULL,
4
5 UserName varchar(30) NOT NULL
6
7);
8
9INSERT INTO @UserMaster VALUES (1,'Rakesh')
10
11INSERT INTO @UserMaster VALUES (2,'Ashish')
12
13INSERT INTO @UserMaster VALUES (3,'Sagar')
14
15SELECT * FROM @UserMaster
16
17DECLARE @CSV VARCHAR(MAX)
18
19SELECT @CSV = COALESCE(@CSV + ', ', '') + UserName from @UserMaster
20
21SELECT @CSV AS Result