Thread: MS SQL Server General Questions/T-SQL concatenate rows into one string

T-SQL concatenate rows into one string

DECLARE @Names VARCHAR(8000)

SELECT @Names = COALESCE(@Names + ', ', '') + CONVERT(varchar(46),   [Code])

FROM [Ecommerce].[dbo].[Store]

  where [StoreTypeID] in  (22,34)

print @Names