简体   繁体   English

SQL Sever 2012 - 生成脚本 - 保存到文件 = 不运行

[英]SQL Sever 2012 - generating scripts - Save to File = Not Run

I am creating scripts of a SQL Server 2012 database because I cannot backup the database to a local drive.我正在创建 SQL Server 2012 数据库的脚本,因为我无法将数据库备份到本地驱动器。 I understand how to create the script but at the end of the process the application seems to get stuck at the Save to file = Not Run.我了解如何创建脚本,但在过程结束时,应用程序似乎卡在保存到文件 = 未运行。

The database is a huge database, but it appears that not much data is being written to the drive.数据库是一个巨大的数据库,但似乎没有太多数据写入驱动器。

This appears to be a bug in SQL Server 11.0.6020 tools.这似乎是 SQL Server 11.0.6020 工具中的一个错误。 There is no trace in event log or server log, the script generator wizard just stops at the last step (which is writing the script to the destination, which can be a file or a new script window - either remains in status "not run" forever, with "Cancel" as the only possible user action).事件日志或服务器日志中没有跟踪,脚本生成器向导只是在最后一步停止(将脚本写入目标,可以是文件或新的脚本窗口 - 要么保持“未运行”状态永远,“取消”作为唯一可能的用户操作)。

Some experimenting showed that it indeed depends on script size.一些实验表明它确实取决于脚本大小。 I was not able to reproduce the problem on any lower or newer version of Microsoft SQL Server.我无法在任何较低或较新版本的 Microsoft SQL Server 上重现该问题。

The solution is annoying: click yourself through the wizard multiple times, first scripting only database definition in parts:解决方案很烦人:通过向导多次单击自己,首先只编写部分数据库定义脚本:

  • datatypes, functions and tables数据类型、函数和表
  • then only views, and然后只有视图,和
  • then only procedures那么只有程序

You can later concatenate the three resulting files if that is a requirement.如果需要,您可以稍后连接三个结果文件。 This approach will not help if any of the three parts alone is bigger than the (unknown) treshold.如果单独的三个部分中的任何一个大于(未知)阈值,则这种方法将无济于事。 Eventually, script the data, selecting only smaller sets of tables for each run.最后,编写数据脚本,为每次运行只选择较小的表集。

As mentioned in one of the comments on the original post, this is still an issue with SQL Server Management Studio v17.9.1 To work around it, I was able to use the "Single file per object" option.正如对原始帖子的评论之一所述,这仍然是 SQL Server Management Studio v17.9.1 的一个问题。为了解决这个问题,我可以使用“每个对象单个文件”选项。 I definitely would have preferred a single file, but at least it worked this way.我肯定更喜欢单个文件,但至少它是这样工作的。 There was still a bit of a delay between the time that the status for all database objects showed Completed and the time that the "Save to file" line item changed from "Not Run" to Completed.在所有数据库对象的状态显示为已完成与“保存到文件”行项目从“未运行”更改为已完成的时间之间仍有一些延迟。

在此处输入图片说明

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

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