Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 select query

Author  Topic 

lkiran086
Starting Member

21 Posts

Posted - 2014-07-02 : 10:46:49
HI All

I have a table contains 40 columns , but I want only the columns names only ...
How can I select ?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2014-07-02 : 10:53:28
see tara's select here:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57418


Too old to Rock'n'Roll too young to die.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-07-02 : 12:49:58
An alternative is to query sys.columns
SELECT * FROM sys.columns WHERE OBJECT_NAME(object_id) = 'YourTableNameHere' ORDER BY column_id;
There is a case to be made for using sys.columns instead of INFORMATION_SCHEMA, unless you have a requirement to be ANSI compliant, e.g. http://sqlblog.com/blogs/aaron_bertrand/archive/2011/11/03/the-case-against-information-schema-views.aspx
Go to Top of Page
   

- Advertisement -