Many time you may need to get list of values from a database table and form a concatenated string (Comma separated). I see still some programmer use cursor to do that. we have simple technique to achieve this.
DECLARE @T VARCHAR(MAX)
SET @T = ''
SELECT @T = @T + COLUMN_NAME + ', '
WHERE TABLE_NAME = 'Metadata' AND TABLE_SCHEMA = 'DBO'
The @T variable will hold all row values separated by comma.