Storing Column Names of a table in CSV Format
DECLARE @commaSeperatedCols VARCHAR ( MAX ) DECLARE @TableName VARCHAR ( 100 ) SET @TableName = 'Your_Table_Name' SELECT @commaSeperatedCols = COALESCE ( @commaSeperatedCols + ',' , '' ) + COLUMN_NAME FROM INFORMATION_SCHEMA . COLUMNS WHERE TABLE_NAME = @TableName SELECT @commaSeperatedCols