Introduction

Consider you need to install a new Cumulative Update or Service Pack on your current SQL Server, but you don't know what's the current update level that already installed on your environment!!

In this article, we will explain How to detect the current Cumulative Update / Service Pack that was installed on SQL Server.

Detect the Current Cumulative Update / Service Pack

You can use the ServerProperty as a system defined function to return the SQL Server Instance information like the ProductLevel and ProductUpdateLevel

The ProductLevel returns the version level of the SQL Server instance as the following.
  • 'RTM' = Original release version
  • 'SPn' = Service pack version
  • 'CTPn', = Community Technology Preview version
Example

select SERVERPROPERTY('ProductLevel') as 'Product Level'


The ProductUpdateLevel returns the update level of the current build as CUn where the CU=Cumulative Update.

Example

select SERVERPROPERTY('ProductUpdateLevel') as 'ProductUpdate Level'



For more details Check the T-SQL: Get SQL Server Instance Information Using SERVERPROPERTY

Note: the ProductUpdateLevel is available at the SQL Server 2012 through current version in updates beginning in late 2015.

Below
we will show How to detect the current Cumulative Update / Service Pack in case the current version doesn't support the ProductUpdateLevel.

Get the current SQL Server Version

You have multiple ways to get the current SQL Server version through the following ways:

Using SQL Management Studio

  • Open SQL Server Management Studio > Connect to SQL Server.
  • Right, click on Server Name > Properties.
  • In General section > Check the Version field number.

Using SQL Configuration Manager

  • Open SQL Server Configuration Manager.
  • From right side > Open SQL Server Services.
  • Right click on SQL Server Instance name > Select Properties.
  • Click on Advanced Tab > Scroll down to version field number.

Using T-SQL


Select @@version

Using WindowsPowerShell

You can use Windows PowerShell to invoke SQL command on a reachable server within the network using Invoke-Sqlcmd cmdlet as the following:

  • Open Windows PowerShell as Administrator
  • Type the Invoke-Sqlcmd with the below parameters.
    • -query: the SQL query that you need to run on the remote server.
    • -ServerInstance: the SQL server instance name.
    • -Username: the username that has sufficient permission to access and execute SQL query on the remote server.
    • -Password: the password of the elevated user.
PS SQLSERVER:\> Invoke-Sqlcmd -query "select SERVERPROPERTY('MachineName') as 'MachineName'" -ServerInstance "epm\epmdb" -Username sa -Password *****



Whatever which method you have used to get the version number, you should now able to detect the current Cumulative Update / Service Pack, as the following:


Conclusion

In this article, we have explained How to determine the current Cumulative Update / Service Pack installed in SQL Server.

Reference

See Also