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
 General SQL Server Forums
 New to SQL Server Programming
 I want a query that returns only the column names

Author  Topic 

raghuram.gupta
Starting Member

3 Posts

Posted - 2007-12-16 : 09:57:30
I want a query that returns only the column names

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-12-16 : 10:00:59
select <columns> from yourtable where 1=0
or
set fmtonly on
select <columns> from yourtable
set fmtonly off

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page

raghuram.gupta
Starting Member

3 Posts

Posted - 2007-12-16 : 10:02:18
what's this 1=0
Go to Top of Page

raghuram.gupta
Starting Member

3 Posts

Posted - 2007-12-16 : 10:06:08
Actually i want a query that return only columns names as column values
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-12-16 : 10:07:14
select column_name
from information_schema.columns
where table_name = 'YourTable'

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page
   

- Advertisement -