bama
bama

Reputation: 129

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.

Upvotes: 7

Views: 4806

Answers (5)

SzilardD
SzilardD

Reputation: 1751

Seems to be a UI issue only, for me the file was created even when it was still shown as 'Not Run' and it contained every exported db object. After a while, it changed into 'Success'

Upvotes: 0

Blax
Blax

Reputation: 35

In SQL Server 2012, I managed to bypass this problem by just closing the SSMS and starting the process of generate scripts again.

Upvotes: 0

Daniel Jonsson
Daniel Jonsson

Reputation: 3933

I'm using SQL Server Management Studio version 18.6. I wanted to export to a query in a new window:

enter image description here

But it resulted in it saying "Not run":

enter image description here

And a few seconds later, it said "Error":

enter image description here

Instead, what worked, was to save the result to a script file:

enter image description here

And here is the successful result:

enter image description here

Upvotes: 1

Eric Barr
Eric Barr

Reputation: 4155

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

enter image description here

Upvotes: 3

Cee McSharpface
Cee McSharpface

Reputation: 8725

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.

Upvotes: 6

Related Questions