Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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.

like image 783
bama Avatar asked Nov 13 '15 18:11

bama


People also ask

How do I save a SQL Server script?

To save a query: Use the Save command in the application toolbar. In the Save File As window, choose a name and a location to save your query.

How do I save a database script?

Right-click on the database that should be exported. On the "Set Scripting Options" you can choose whether to save or publish the script. Once you customize all the desired save and advanced options, click the "Next >" button. Clicking the "Advanced" button would allow you to customize the exported content.


1 Answers

This appears to be a bug in SQL Server 11.0.6020 tools. 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.

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.

like image 50
Cee McSharpface Avatar answered Oct 11 '22 01:10

Cee McSharpface