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

前端 未结 4 616
甜味超标
甜味超标 2021-01-31 08:37

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

4条回答
  •  隐瞒了意图╮
    2021-01-31 09:19

    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.

提交回复
热议问题