Hot to Determine SQL Server version from a Backup File

⚠️NOTE: This procedure will only work when testing a SQL Server less than (or equal to) the one you are using.

restore headeronly from disk = N'C:\temp\db.bak'

Here is a list of SQL Server versions and their compatibility levels from SQL Server 2008 to version SQL Server 2017.

SQL Server VersionInternal Database VersionDatabase Compatibility Level
SQL Server 2022957160
SQL Server 2019904150
SQL Server 2017869140
SQL Server 2016852130
SQL Server 2014782120
SQL Server 2012706110
SQL Server 2008 R2660/661100
SQL Server 2008655100

You can compare the column DatabaseVersion from the result set with Internal Database version to determine the version of the database.

(Attribution)

Revised: 2018-12-21