Aggregate field to comma separated text



--Works good with numbers, careful with text due to xml-conversion

select stuff(
(
select ','+AnimalId
from dbo.Animal as a
for xml path('')
),
1,1,'') AS AggregatedAnimalIdsAsString

Comments

Popular posts from this blog

How to decrypt stored password from SSMS registered servers

How to fail sql server agent job if powershell script fails

Cause for Parameter is incorrect 0x80070057 error in ssis