简体   繁体   中英

SQL Server Schema Output

How do I output the schema of my database? I want it to output the design of the database.

Something like this might work:

 SELECT TABLE_TYPE, TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
 FROM INFORMATION_SCHEMA.COLUMNS
 ORDER BY TABLE_TYPE, TABLE_NAME, COLUMN_NAME 

But I can't get it to run correctly. A excel file with table names, their columns, types, primary keys, etc. is what I want.

select 
t.type_desc,
t.name as [table], 
c.name as [column],
y.name,
c.max_length
from sys.tables t inner join
sys.columns c on c.object_id = t.object_id inner join
sys.types y on c.system_type_id = y.system_type_id
where y.name <> 'sysname'
order by 
t.type_desc,
t.name, 
c.name
SELECT * FROM INFORMATION_SCHEMA.TABLES; 

...听起来像您要找的东西,没有任何您想要的格式。

Below posts would be useful for generating data dictionary

Database Documentation - http://deepakrangarajan.blogspot.com/2011/03/database-documentation.html

Generating a Database Data Dictionary - http://sqlserverdiaries.com/blog/index.php/2011/02/generating-a-database-data-dictionary/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM