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 2000 Forums
 SQL Server Development (2000)
 How To Return Column Names and other Table Info?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-08 : 08:42:26
John writes "I have been searching all over for a list of table object attributes that can be queried. I could swear i remember being able to query a table to get back info about the table such as:

select FIELDNAMES from Employees; (for instance)

That might return something like:

FIELDNAMES
------------
emp_id
emp_name
emp_title
emp_ext

etc..

and it would return the actual names of each field. is this possible anymore? i cannot find anything on the web about it, but i may not posess the correct vocabulary to reference these techniques correctly in my search.

if it is possible, can you direct me to a list of all possible table objects that are queryable?

thank you for your help.

John Hartigan"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-08 : 08:48:32
If you are using SQL Server, you want to either look at the syscolumns table or the information_schema.columns view.

<O>
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-08 : 08:48:55
Yes, you're looking for the INFORMATION_SCHEMA views. For your Employees table, something like this would work:

SELECT * FROM databasename.INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='Employees'


There are more INFORMATION_SCHEMA views available, they are all documented in Books Online.

@#$@$%@!!@#$!$ SNIPERS!



Edited by - robvolk on 07/08/2002 09:03:57
Go to Top of Page
   

- Advertisement -