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 2005 Forums
 Transact-SQL (2005)
 Need SQL View that Shows TableNames, ColumnNames,

Author  Topic 

gjohnso7
Starting Member

11 Posts

Posted - 2009-04-30 : 12:12:11
I need a SQL View that Shows TableNames, ColumnNames for the entire DB I am working with. I need to be able to export this to excel and use it as a reference.

Table_Name, Column_Name, Data_Type

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-04-30 : 12:12:56
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-30 : 23:13:14
use robvolk query and
try this one for tablename and their respective columnnames

select t.name as tablename,s.name as columnname from sys.tables t
inner join sys.columns s on t.object_id = s.object_id
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 01:11:16
quote:
Originally posted by bklr

use robvolk query and
try this one for tablename and their respective columnnames

select t.name as tablename,s.name as columnname from sys.tables t
inner join sys.columns s on t.object_id = s.object_id




No, just use the information_schema view as it provides everything already. Don't use the system tables unless there is something not available in the information_schema views.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -