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.
Author |
Topic |
lkiran086
Starting Member
21 Posts |
Posted - 2014-07-02 : 10:46:49
|
HI AllI 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 |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-07-02 : 12:49:58
|
An alternative is to query sys.columnsSELECT * 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 |
|
|
|
|
|