May 6, 2009 at 1:36 am
Hi all,
I have a table like
T1
==================
Name Address
==================
abc xyz
I need the result of select query as
=========
fields
=========
Name
Address
How can i do this. Please help.
Thanks
Nitin
May 6, 2009 at 1:45 am
select name from sys.columns where object_id = object_id('Tablename')
"Keep Trying"
May 6, 2009 at 6:23 am
or
Select column_name from information_schema.columns
where table_name='your_table'
Failing to plan is Planning to fail
May 6, 2009 at 6:55 am
Tables have fields???? 😀
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
May 6, 2009 at 7:08 am
I agree with the use of the information_schema instead of the system tables. There've been quite a few changes in how those system tables behave, what you can, etc., between 2000 & 2005/2008. The information_schema is pretty stable & standard between all the versions. A much better place to go.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply