How to determine your SQL Azure database compatibility level?

This morning, one developer of my team asked me what was the SQL version of one of our production databases to see if he could use newer SQL syntax in a query.

If you use SQL Management Studio you can get the SQL server version in the object explorer of Management Studio.

SQLManagerSQLVersion

In this example, the server version is 12.0.2000.8 which could be interpreted as a SQL Server 2014.

ref : https://support.microsoft.com/en-ca/help/321185/how-to-determine-the-version-edition-and-update-level-of-sql-server-an

But using SELECT @@VERSION you can get a different version

SQLVERSION

In this example , it seem to be SQL Server 2016.

So physical SQL server and Azure SQL server version number aren’t the same.

But What really matter is the compatibility level which is what you looking for when you want to use newer SQL syntax.

The alignment of SQL versions to default compatibility levels are as follows:

  • 100: in SQL Server 2008 and Azure SQL Database
  • 110: in SQL Server 2012 and Azure SQL Database
  • 120: in SQL Server 2014 and Azure SQL Database
  • 130: in SQL Server 2016 and Azure SQL Database
  • 140: in SQL Server 2017 and Azure SQL Database

ref: https://azure.microsoft.com/en-us/blog/default-compatibility-level-140-for-azure-sql-databases/