Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I list columns in a table?

Status
Not open for further replies.

gArmitage

Programmer
Aug 9, 2001
4
GB
Hi,

Does anybody know how I can get a list of all the columns in a table? And then get the attributes of those columns?

Many thanks,

Grahame
 
This should do the trick:

Code:
select * from syscolumns where id =
(
    select id from sysobjects where name = 'myTable'
)
X-) Billy H

bhogar@acxiom.co.uk
 
Hi,
The preferred way is to use the the information schema views
because system tables may change
ex:

select * from information_schema.columns

here, information_schema is the owner and columns is the name of the view. The are other interesting views to interogate and they are all contained in the database model so when you create a new database you'll have them.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top