2
Answers

How to get comma separated value..?

Photo of santosh parida

santosh parida

12y
1.4k
1
My query is

select ContactId from dbo.ContactGroupReln where ContactGroupId=@ContactGroupId

through this query i want to get the comma separated list..Can any body help me pls..

Answers (2)

0
Photo of Muralidharan Deenathayalan
NA 11.9k 1.5m 12y
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
Photo of Anurag Sarkar
NA 2.4k 308k 12y
Please check this link and try the query out there http://www.c-sharpcorner.com/UploadFile/ff2f08/comma-separated-value-in-sql-query/