Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 475
Thiago Leão Moreira Avatar asked Jul 01 '10 15:07

Thiago Leão Moreira


2 Answers

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

like image 55
Baaju Avatar answered Sep 26 '22 23:09

Baaju


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

like image 25
etliens Avatar answered Sep 26 '22 23:09

etliens