Get Column Names of Table – Microsoft Sql
2 March 2011
1,377 views
No Comment
This is how you can get the name of the columns from a table in MS SQL.
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = ‘TableName’
And if you want them as a comma separated list:
declare @list varchar(max)
select @list=COALESCE(@list+’, ‘,”)+COLUMN_NAME
FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = ‘TableName’
select @list
______________
From Webcosmo Webmaster Forum http://www.webcosmoforums.com/databases/27234-get-column-names-table-microsoft-sql.html










Leave your response!