-5

I Have Two Table something like in this image.

I Need Comma Separated data like that of in this.

StackUseR
  • 884
  • 1
  • 11
  • 40
  • there is STRING_SPLIT function introduced in SQL Serrver 2016..Finally ! – Mudassir Hasan Nov 22 '16 at 06:49
  • 2
    I so wish there was option to close a question sighting `Not enough efforts to find solution`. – Mahesh Nov 22 '16 at 06:54
  • can u check m answer .@krishna prajpati – Chanukya Nov 22 '16 at 07:07
  • Possible duplicate of [Summarize the list into a comma-separated string](http://stackoverflow.com/questions/9811577/summarize-the-list-into-a-comma-separated-string) – Jibin Balachandran Nov 22 '16 at 08:31
  • Possible duplicate of [Turning a Comma Separated string into individual rows](http://stackoverflow.com/questions/5493510/turning-a-comma-separated-string-into-individual-rows) – Matt Nov 22 '16 at 11:32

2 Answers2

1
select distinct t.[name],
  STUFF((SELECT distinct ', ' + t1.notification
         from yourtable t1
         where t.[id] = t1.[id]
            FOR XML PATH(''), TYPE
            ).value('.', 'NVARCHAR(MAX)') 
        ,1,2,'') notification
from yourtable t;
Chanukya
  • 5,833
  • 1
  • 22
  • 36
1
SELECT id , Name ,
 STUFF ( ( SELECT ',' + Noti FROM Your_table T1 WHERE T1.Id = T2.Id FOR XML PATH('') ) ,1,1,'') 
FROM Your_table T2 GROUP BY id ,Name
TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
Mansoor
  • 4,061
  • 1
  • 17
  • 27