Get Column Names for Table in MSSQL

by Nathan 3. February 2009 17:26

To get the column names of a table in MSSQL 

SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'TableName'

This is basically the MSSQL equivalent for The MySQL Command DESCRIBE TableName which displays the table details

 

I often use this so i can copy and paste into another query etc.

SELECT Column_Name + ',' FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'TableName'

then i have the commas for use in any INSERT or SELECT etc Smile

 

Tags:

SQL

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen