Link to home
Start Free TrialLog in
Avatar of pdlarue
pdlarue

asked on

Want to query for column names in a table or Describe (Not T-SQL, just SQL query)

I have a million tables to look at.  I want to get the column names without having to retype them.  

DESCRIBE tablename - is giving me an error

SELECT COLUMN_NAME from information_schema WHERE TABLE_NAME = 'tablename' - is giving me an error - Should the information_schema be replaced with the database name or is information_schema a Microsoft provided system schema?

Do I need special privileges?

I'm not using T-SQL, just plain SQL Queries.  Can anybody help me find a way to get the column names in a list from the database?

Thank you in advance,
Patricia

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdlarue
pdlarue

ASKER

angellll:

I got it.  Thank you.  I'll give you the points but can you maybe tell me how to get a data dictionary from
SQL Server?  I have 12 databases and nobody has done any documentation on it at all; not even an ER Diagram.

Thank you,
Patricia
the information_schema gives all the technical implementation, but there is no tool to give you a diagram unless there are primary key + foreign key contraints set up...

Avatar of pdlarue

ASKER

Thank you, angellll, you have been very helpful.  I found the following SQL that gave me a resultset of all tables and their column information.  I just had to query each database.  This might be helpful to you or others in the future.

     SELECT * FROM information_schema.columns

Thanks again,
Patricia