How to clone structure of DB

  • I want to clone structures of main DB (tables, views, sp, ...not data) to test DB for testing purpose

    I use "Generate SQL scripts", but they lack info of Trigger, Column default values, ....

    How to do to clone enough structures?

    Thanks

  • thang_ngo_2002 (6/18/2009)


    I want to clone structures of main DB (tables, views, sp, ...not data) to test DB for testing purpose

    I use "Generate SQL scripts", but they lack info of Trigger, Column default values, ....

    How to do to clone enough structures?

    Thanks

    Right click database>all task>generate sql script, a window opens

    go to options> check script triggers, and script primary/foreign keys/defaults.

    There are other options there which you might want to have a look at to script out everything u need.



    Pradeep Singh

  • Have a look at the "Options" tab on the dialog... you'll see checkboxes for triggers etc.

  • There are options you need to select in Enterprise Manager (I believe, its been a long time since I used it) that will allow you to include those in your scripts. I believe you will find it under options, in EM or QA. Best place to check is in Books Online (BOL, the SQL Server Help System).

  • Ok, I see, thanks you so much

  • I use Redgate SQL Compare to build full schema copies of databases. Here is the process:

    1) Create a brand new empty database

    2) Run SQL Compare and select the existing database and newly created empty database

    3) Synchronize the databases

    Only takes a few minutes - and shows that the toolset is quite worth the cost. The next thing that can be done is to build a SQL Data Compare project that will then perform the data comparison for your static tables (e.g. lookup tables, configuration tables, etc...).

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • You could also just restore a full backup from your production database into a new test database. You would just need to enable the logins for the new database.

    I just noticed that you don't want the data. You could run a truncate for each table to get rid of the data.

    Steve

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply