Sql Server comma separated(,)

Example:

Ram
shyam
Golu
Chintu


(This query will give space only)

DECLARE @Str varchar(max)
SELECT @Str=COALESCE(@Str,'') + CAST(ColumnName as varchar(100)) + ' '
FROM  TableName
SELECT @Str


(This query will give comma(,)

DECLARE @Str varchar(max)
SELECT @Str=COALESCE(@Str,'') + CAST(ColumnName as varchar(100)) + ','
FROM TableName
SELECT @Str

Output:
Ram,Shyam,Golu,Chintu