Facebook Twitter Reddit LinkedIn

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: http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx
© 2007-2018 All rights reserved.   Part of the somuch.com group of trusted web sites.   PO Box 1542, Ormond Beach FL 32175