You are here: Sysadmins of the North » Windows Server » Install SQL Server cumulative updates silently

Install SQL Server cumulative updates silently

Install SQL Server update silent: installing SQL Server cumulative updates is always a cumbersome, and quite daunting task. Unpacking and running the CU installer is a slow process, you have to click through a lot of screens, and it’s hard to get it to install silently. But here is how!

Learn how to install SQL Server cumulative updates (CU) silently using PowerShell opposed to the cumbersome task of running the GUI installer.

Imagine you’re installing Cumulative Update Package 13 for SQL Server 2019, or KB5005679. What you need to know is the file you downloaded (SQLServer2019-KB5005679-x64.exe) is a wrapper around the update’s setup.exe program. So any setup parameter passed on the command line, isn’t passed on to setup.exe! Therefore, the first step is to unpack the file into a temporary location from where you run the setup.

The following command unpacks SQLServer2019-KB5005679-x64.exe into the location Z:\sqlserver_cu\KB5005679:

.\SQLServer2019-KB5005679-x64.exe /X:Z:\sqlserver_cu\KB5005679

In the folder KB5005679 you’ll find the SQL Server cumulative update setup.exe file you so desperately need to install this update silently. Now only for the command line arguments…

All relevant command line arguments are in Microsofts online doc Installing Updates from the Command Prompt. For me, the minimal set I go with are:

  • /action=patch
  • /instancename=MSSQLSERVER
  • /quiet
  • /IAcceptSQLServerLicenseTerms

The /quiet switch runs the update in unattended mode, making the command to install SQL Server cumulative updates silent and unattended:

# silent and unattended install of a service pack to a specific SQL Server instance
Z:\sqlserver_cu\KB5005679\setup.exe /action=patch /instancename=MSSQLSERVER /quiet /IAcceptSQLServerLicenseTermsCode language: PHP (php)

In your deployment scenario, you can add some logic and checks to apply the update only if its ProductVersion property is higher than currently installed. You’ll need Invoke-SqlCmd for this too:

$sqlserver_version = New-Object System.Version $(Invoke-SqlCmd -Query "SELECT SERVERPROPERTY('ProductVersion') AS BuildNumber").BuildNumber
if($sqlserver_version -ne (New-Object System.Version $(Get-ItemProperty "Z:\sqlserver_cu\KB5005679\setup.exe\setup.exe").VersionInfo.ProductVersion)) {
	Z:\sqlserver_cu\KB5005679\setup.exe /action=patch /instancename=MSSQLSERVER /quiet /IAcceptSQLServerLicenseTerms
}Code language: JavaScript (javascript)

Show Your Support

donate with Paypal

If you want to step in to help me cover the costs for running this website, that would be awesome. Just use this link to donate a cup of coffee ☕($10 USD or €10 EUR for example). And please share the love and help others make use of this website. Thank you very much! <3 ❤️

2 thoughts on “Install SQL Server cumulative updates silently”

  1. Nice. We were just looking to do something like this in our environment. I imagine you could change the local file path to a UNC share instead, right?

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top