Thursday, September 12, 2019

How to Get Comma Separated values in SQL Server with STUFF

Select Distinct  STUFF(( 
  select Distinct ';'+ Name from tablename
 Name is not null and Emailaddress<>''
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'') Name 

No comments:

Post a Comment