How to put a column into a delimited form

use northwind
Declare @ColumnList varchar(1000)
SELECT @ColumnList = COALESCE(@ColumnList + ', ', '') + column_name
FROM INFORMATION_SCHEMA.Columns
WHERE table_name = 'Orders'

Source: https://weblogs.sqlteam.com/mladenp/2005/08/01/7421/
Viewed 17246 times