MSSQL View SQL from GUI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thecolonel
    New Member
    • Mar 2008
    • 1

    #1

    MSSQL View SQL from GUI

    In Oracle, as I'm using the GUI to create tables, I can also look at older tables and the SQL it would take to create those tables again. Does MSSQL 2005 have this same feature anywhere in the Management Studio? I ask because I need to create a large number of tables that already exist in this database in a different place, so it would be nice if I could just view the script it would take to create these tables rather than having to write all the script from scratch myself. Any help would be appreciated.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by thecolonel
    In Oracle, as I'm using the GUI to create tables, I can also look at older tables and the SQL it would take to create those tables again. Does MSSQL 2005 have this same feature anywhere in the Management Studio? I ask because I need to create a large number of tables that already exist in this database in a different place, so it would be nice if I could just view the script it would take to create these tables rather than having to write all the script from scratch myself. Any help would be appreciated.
    Open Management Studio. Connect to your server. Go to your database. Expand Tables. Right Click on the table that you want. Choose CREATE to. Then choose where you want the script to go.

    How many tables are we talking about? It might be faster if you just copy the database and truncate all the tables. Or go to the source database and do a

    Code:
    select * into newdb..newtable from olddb..oldtable where 1 = 2
    -- CK

    Comment

    Working...