Here I will create one table and insert multiple rows.
DECLARE @Name_Mast TABLE (
[Name] VARCHAR(20)
)
INSERT INTO @Name_Mast ( [Name] )
VALUES ( 'Nikhil' ), ( 'Bhumi' ), ('Keyur'), ('Nikunj')
After that we will run this query for get comma sepreted string of column value.
SELECT STUFF((SELECT ',' + [Name]
FROM @Name_Mast
ORDER BY [Name]
FOR XML PATH('')), 1, 1, '') AS [Output]
Output: "Bhumi,Keyur,Nikhil,Nikunj"
