To get column values in one comma-separated value in SQL.
DECLARE @UserMaster TABLE(
UserID INT NOT NULL,
UserName varchar(30) NOT NULL
);
INSERT INTO @UserMaster VALUES (1,'Krishna')
INSERT INTO @UserMaster VALUES (2,'Arpit')
INSERT INTO @UserMaster VALUES (3,'Sandeep')
SELECT * FROM @UserMaster
DECLARE @CSV VARCHAR(MAX)
SELECT @CSV = COALESCE(@CSV + ', ', '') + UserName from @UserMaster
SELECT @CSV AS Result
Check out our SQL Online Course to have a complete grip on SQL concepts.