SQL Server 2012 无数据复制数据库 [英] SQL Server 2012 copy database without data

查看:60
本文介绍了SQL Server 2012 无数据复制数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 SQL Server 2012 数据库,其中包含我们用来开发网站的测试数据.我们很快需要清空数据库并导入真实数据,但是我们在Web开发过程中多次更改了数据库设计,因此无法使用我们在开始时创建的空副本!

We have a SQL Server 2012 database with test data in it that we used to develop a website. We will shortly need to empty the database and import the real data, but we have changed the database design many times during the web development, so we cannot use the empty copy we created at the start!

有没有办法复制数据库,没有数据但有其他所有内容(包括视图、SP 函数、安全对象等),并将所有索引重置为设计种子值?换句话说,我们希望保持数据库原样,但删除所有数据,将所有表索引重置为其原始设计种子值,然后导入数据.

Is there a way to copy the database, with no data but with everything else (including views, SPs functions, security objects etc), and resetting all the indexes to the design seed value? In other words, we would like to keep the database exactly as it is but delete all the data, reset all the table indexes to their original design seed values and then import the data.

感谢收到任何帮助

推荐答案

  1. 右键单击服务器中的数据库,然后选择 Tasks >生成脚本.
  2. 在介绍步骤,点击下一步.
  3. 在选择对象中,您可以选择整个数据库(包括函数等)或指定要生成的对象.在您的情况下,您应该选择编写整个数据库和所有数据库对象的脚本,然后点击下一步.
  4. 选择您的文件名和目的地,然后点击下一步
  5. 查看然后点击下一步
  6. 完成!

您将看到在指定文件夹中生成的 .sql 文件.您可以在其他服务器上打开该文件并点击执行,它将生成一个完全相同的数据库.

You will see a .sql file generated in your specified folder. You can open that file in other servers and hit execute, it will then generate a exact same database.

这篇关于SQL Server 2012 无数据复制数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆