Which SQL command can I use to see the structure of a table on SQL Server?

懵懂的女人 提交于 2019-11-27 15:57:56

问题


I have a table on a SQL Server and I would like to export its structure to send to a colleague. Which SQL command should I issue to get the structure? I don't have access to the SQL Server Management Studio.


回答1:


sp_help '<TableName>'

will give you the structure of a table

Also you can use the information_Schema to get a detailed information,

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TableName' 

Check this out http://msdn.microsoft.com/en-us/library/ms186778.aspx




回答2:


Brad Schulz has a pretty awesome DDL generating script he just blogged about the other day: (there are a few limitations with it though)

http://bradsruminations.blogspot.com/2010/06/more-fun-with-hyperlinks-ddl-code.html




回答3:


Visual Studio has tools for designing and browsing database schema under Data Connections in Server Explorer. Certain versions also have full schema and data comparison tools similiar to Red Gate's Sql Compare



来源:https://stackoverflow.com/questions/3159236/which-sql-command-can-i-use-to-see-the-structure-of-a-table-on-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!