show Create commands for table in SQL Management Studio (2008)

14,490

Solution 1

In Object Explorer, expand your server/database, expand Tables, right-click the table in question, and choose Script Table as > CREATE To > New Query Editor Window.

If you want to script multiple tables, you can turn on Object Explorer Details (F7 or from the View menu), highlight "Tables" on the left, then use Shift+ or Ctrl+ to select multiple tables in the right pane (just like you would select multiple files in Windows Explorer). Then you can do the same thing, right-click, Script Table as > ...

Solution 2

If you want to generate script for one table, right click a table and select "Script table as", you get all sorts of options including creating the create script of the table.

Generate script for single table

If you want to generate scripts for more than one table, you have option to generate for many at once. Just follow the wizard instructions.

Generate scripts for many tables

Share:
14,490

Related videos on Youtube

Gabbo
Author by

Gabbo

Updated on July 03, 2022

Comments

  • Gabbo
    Gabbo almost 2 years

    I've just started with SQL Management Studio and I am wondering if I can show create commands for already existing tables, I've been able to do that in Oracle SQL Developer.. I've tried to ask uncle google but maybe used just wrong search command.. Anyway.. could someone give me quick hint as I stuck with this for like 25 minutes? Thanks

  • Adir D
    Adir D almost 12 years
    Clicking "Drop" just generates a script, so it's ok to click that accidentally, but if you click that accidentally and run it accidentally, I'm not sure who you could blame but yourself. :-)