简体   繁体   English

Microsoft SQL Server 2005在* .sql中备份数据库

[英]Microsoft SQL Server 2005 backup the database in *.sql

I work in a small company which is running M/S SQL Server 2005 Now our head office is asking me to give the whole database backup with the table schema in a single file of *.sql 我在一家运行M / S SQL Server 2005的小公司里工作,现在我们的总公司要我在一个* .sql文件中以表模式对整个数据库进行备份

please help me to backup my database in a *.sql including the table schema. 请帮助我在* .sql(包括表模式)中备份数据库。

Thanks in advance. 提前致谢。

Use SQL Server Management Studio 使用SQL Server Management Studio

  1. right click on your database and choose Generate scripts... and hit Next 右键单击数据库,然后选择“ Generate scripts...然后单击“ Next
  2. choose Script entire database and all database objects and hit Next 选择Script entire database and all database objects然后单击Next
  3. choose Save to file and enter a path and a file name for your future sql script file. 选择“ Save to file ,然后为将来的sql脚本文件输入路径和文件名。 On the same screen choose Advanced and change the Types of data to script property value from Schema only to Schema and data . 在同一屏幕上,选择“ Advanced然后将“ Types of data to script属性值从“ Schema only Schema and data更改为“ Schema and data Hit OK . 点击OK Hit Next . 点击Next
  4. and hit Next again. Next再次点击Next

You can download , install, and use SQL Server Management Studio that comes free with Microsoft® SQL Server® 2012 Express for that 您可以为此下载 ,安装和使用Microsoft®SQLServer®2012 Express附带的免费SQL Server Management Studio

I would go out and download Microsoft SQL Server Management Studio Express. 我将出去下载Microsoft SQL Server Management Studio Express。

http://www.microsoft.com/en-us/download/details.aspx?id=8961 http://www.microsoft.com/en-us/download/details.aspx?id=8961

It is free. 这是免费的。 You will be able to connect to the database, drill down into Databases, right click and under Tasks, pick Backup Database. 您将能够连接到数据库,向下钻取到数据库,右键单击并在“任务”下选择“备份数据库”。 Make sure you pick full...CHoose Disk as the place you want to write it to and Execute...Look thru your options as well... 确保选择完整的...选择磁盘作为要写入的位置并执行...也请通过选择查看...

Hope this helps! 希望这可以帮助!

I'd go with the method peterm suggested but note that this also has flaws. 我会建议使用peterm建议的方法,但请注意,这也有缺陷。 Problem is that SSMS doesn't order the scripts in correct execution order. 问题是SSMS没有按正确的执行顺序对脚本进行排序。

For example, it might happen that DDL for stored procedure P is before DDL for table T that is used in P. 例如,可能会发生存储过程P的DDL在P中使用的表T的DDL之前。

All you need to do is to review your script and make sure there are no such cases. 您需要做的就是检查脚本并确保没有这种情况。 If there are you can try fixing this yourself or using some third party tool to generate script that is ordered correctly. 如果有,您可以尝试自己修复此问题,或使用某些第三方工具生成正确排序的脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM