Alex Gordon
Alex Gordon

Reputation: 60731

Show create table tablename in SQL Server

In MySQL it is possible to do show create table tablename

What is the SQL Server equivalent?

Upvotes: 33

Views: 60028

Answers (4)

WEBjuju
WEBjuju

Reputation: 6581

In addition to mentions that SSMS has a contextual menu option, I see that Azure Data Studio also has a "Script as Create" in the right-click context for the table:

azure data studio, right click table, "Script as Create" in contextual menu

Upvotes: 0

mangu
mangu

Reputation: 41

if multiple database and schema exists in SQL_Dataserver, Then you need to provide the exact table location with sp_help within single quotes.

exec sp_help 'database_name.schema_name.table_name'

Upvotes: 1

Danniel Little
Danniel Little

Reputation: 811

One that might be close:

exec sp_columns YourTableName

Upvotes: 12

Will A
Will A

Reputation: 24988

In SSMS, right-click on the table node and "Script Table As" / "Create".

There is no built in 'script this table' T-SQL.

sp_help 'tablename' gives useful table information if that'd do.

Upvotes: 40

Related Questions