MS SQL 2008 - Create a copy of the database without the data

user380527 picture user380527 · Oct 12, 2010 · Viewed 60.8k times · Source

In MS SQL Server 2008 R2, how do I create a new database based on the schema of the old one, but without copying any of the data along with it? I am using SQL Server management studio.

Answer

codingbadger picture codingbadger · Oct 12, 2010

Right click the Database and select Tasks -> Generate Scripts.

You can you then select all the objects you require or only certain objects.

There are some Script Options that you should look at:

  • Script USE DATABASE - You should set this to false if you are creating a new database with a different name.
  • Indexes & Triggers are not scripted as default
  • Logins & Object Level Permissions are not scripted as default
  • Generate Script for Dependent objects - this is set to false as default but you may want to change it to true to ensure that all objects are scripted.

You can either create these to a new Query Window or save them to SQL Files.