Error Applying SQL Server 2012 SP2 with Availability Groups

By:   |   Comments (3)   |   Related: > Upgrades and Migrations


It's time to apply SQL Server Service Pack 2 to your SQL 2012 instances. Normally the installation of SQL 2012 Service Pack 2 is pretty straightforward even for replicas involved in an Availability Group. But for your SQL Server 2012 instances that include Integration Services for your Availability Groups, you might encounter an error similar to:

The Script level upgrade for database 'master' failed because upgrade step 'SSIS_hotfix_install.sql' encountered error 945, state 2, severity 25. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.

The Service Pack 2 update for SQL Server 2012 has a hotfix that needs to be applied to the SSISDB database. If the SSISDB database is involved in an Availability Group, it cannot apply the hotfix. To work around this, you need to remove the SSISDB from the Availability Group, apply the hotfix then add the SSISDB back into your Availability Group.

For this kind of error, you need to do the following:

  • Start the MSSQLSERVER instance with trace flag 902 from your cmd window as shown below.
start sql from cmd line with trace flag 902
  • In SQL Server Management Studio (SSMS), remove the SSISDB database from the Availability Group. Alternatively, you may execute the following statement. For this step, you will need CONTROL SERVER permission or at least ALTER AVAILABILITY GROUP permissions.


  • In Windows Explorer, go the location of the binary files for your SQL Server such as (C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Install) and open up the SSIS_HOTFIX_INSTALL.SQL file and execute in a SSMS query window.
  • Stop the MSSQL service from SQL Server Configuration Manager.
  • Start the MSSQL service from SQL Server Configuration Manager as you would normally do.
  • On the Primary server, perform a full backup and transaction log backup of the SSISDB database. Copy the backup files to the secondary server and restore with the NORECOVERY option.
  • From your primary server, add the SSISDB database back into your Availability Group. Alternatively, you execute the following statement:

    ALTER AVAILABILITY GROUP [yourAGgroup] ADD DATABASE [databasename];

After this, you should be able to check that the build number for SQL Server 2012 is something like 11.0.5058 within SSMS. Your Service Pack 2 patch is complete and you can get your coffee now.

Next Steps
  • Perform the necessary health check especially with your Integration Services and SSIS packages prior to any upgrades.
  • For more tips on Availability Group, click here.
  • For more tips on upgrades and migrations, click here.
  • Learn more about Availability Groups in this webcast.

sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip

About the author
MSSQLTips author Carla Abanes Carla Abanes is a certified Microsoft SQL Server Database Administrator with extensive experience in data architecture and supporting mission critical databases in production environments.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips

Comments For This Article

Monday, June 19, 2017 - 10:24:51 PM - carla abanes Back To Top (57775)

Hi Saravanan,


Glad to be of help! Happy new work week to you! 


Sunday, June 18, 2017 - 2:58:47 PM - Saravanan N K Back To Top (57680)

Hi  Carla,

It was really a great work around, we faced similar issue. We were in the middle of Critical DB SP upgrade and we got the same error. And Billion thanks for sharing the work around, it worked great.



Monday, June 15, 2015 - 5:01:43 PM - Pavan Srirangam Back To Top (37930)

I ran into this issue and got resolved long back even when I installed SP2 , Basically it is trying to execute a T-SQL script on the secondary SSIDB which is not accessible, making it accessible should let the SP2  to execute a script on that. there is other way of doing but this is what is recommended approach, thanks for sharing.

get free sql tips
agree to terms