select column_name,* from information_schema.columns where table_name = 'YourTableName' order by ordinal_position
This worked fine in my SQL 2008 instance but I got an invalid object name using it on some SQL 2005 boxes.
The fix is to put it in caps. select column_name,* from INFORMATION_SCHEMA.COLUMNS where table_name = 'SOP30300' order by ordinal_position
Very useful since it returns the table fields and a good deal of information regarding them. SOPTYPE DEV dbo SOP30200 SOPTYPE 1 smallint SOPNUMBE DEV dbo SOP30200 SOPNUMBE 2 char ORIGTYPE DEV dbo SOP30200 ORIGTYPE 3 smallint ORIGNUMB DEV dbo SOP30200 ORIGNUMB 4 char DOCID DEV dbo SOP30200 DOCID 5 char DOCDATE DEV dbo SOP30200 DOCDATE 6 datetime GLPOSTDT DEV dbo SOP30200 GLPOSTDT 7 datetime QUOTEDAT DEV dbo SOP30200 QUOTEDAT 8 datetime QUOEXPDA DEV dbo SOP30200 QUOEXPDA 9 datetime ORDRDATE DEV dbo SOP30200 ORDRDATE 10 datetime INVODATE DEV dbo SOP30200 INVODATE 11 datetime BACKDATE DEV dbo SOP30200 BACKDATE 12 datetime RETUDATE DEV dbo SOP30200 RETUDATE 13 datetime ReqShipDate DEV dbo SOP30200 ReqShipDate 14 datetime
Curt Spanburgh Microsoft Certified Business Solution Specialist. Dynamics CRM MVP Contributing Editor, Windows IT Pro
He that is walking with wise persons will become wise, but he that is having dealings with the stupid ones will fare badly. Proverbs 13:20