views:

100

answers:

6

Hi there,

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.

Thanks

+15  A: 
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

Baaju
This is awesome.
BC
A: 

Get, and tell him to get, DBVisualizer. :-)

glowcoder
A: 

MS SQL Server Management Studio has the capability to export the table's DDL, as well as many other 3rd party tools (Aquafold, DBArtisan, etc...).

Rawheiser
He said he doesn't have access to SQL Studio.
Loadmaster
That's why I added the list of other tools, and refined his question to specify DDL extraction.
Rawheiser
A: 

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

BC
+1  A: 

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

etliens
A: 

sp_help tablename

kacalapy