0
Here is another simple of doing this.
DECLARE @listContactIdStr VARCHAR(MAX)
select @listContactIdStr = COALESCE(@listContactIdStr+',' ,'') +ContactId from dbo.ContactGroupReln where ContactGroupId=@ContactGroupId
SELECT @listContactIdStr
Please let me know, if it is not helping you.
0
Please check this link and try the query out there
http://www.c-sharpcorner.com/UploadFile/ff2f08/comma-separated-value-in-sql-query/