show Create commands for table in SQL Management Studio (2008)
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.
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.
Related videos on Youtube
Gabbo
Updated on July 03, 2022Comments
-
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 almost 12 yearsClicking "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. :-)