How to replicate a database w/o the data

  • I need to replicate a database, tables, views, objects, etc... without any of the existing data that is in there now.  I found a way to do this with tables, but not the entire database.

    Is there a simple way to do this?

    Thanks in advance for any help you can give me.

     

  • In Enterprise Manager, right click on the database, select "All Tasks", then "Generate SQL Scripts".  In the dialog box that comes up, click on the "Show All" button, then select the "Script All Objects" box.  At this point, you can click "OK" and save the resulting script, or click "Preview" and copy it into the clipboard, paste it into Query Analyzer, and modify it or run it.

    Steve

  • Does this give you the chance to rename the database?

  • YES you have an option to change the database name i.e,

    sp_renamedb @dbname @newname

  • You could always use the DTS copy objects task - it gives you the copy with/without data option plus a lot more.

  • Using the create SQL task, does this duplicate the SQL account assigned to the database as owner?

    Thanks again

  • Terry, I won't tell you that my way is better than anyone else's, but if you decide to go that route, when you script the database, you have an opportunity to change the database name, file names, and anything else you wish to change before creating the new database.  You'll be copying the script into a Query Analyzer window, and from there you can make any changes you want.  You also have the ability to choose which objects to script, including users (available on the options tab of the script dialog). Once you have the script the way you want it, just execute it, and you've got your copy.

    Steve

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

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