Friday, January 8, 2016

Concatenate values of single column with multiple records into a single string using SQL

DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ',', '') + itemRef FROM TableName Where activityRef = '123123'
Select @Names