Sql-server – “Cannot open database version 706. Upgrade the database to the latest version” – when trying to use availability database for read-only access

availability-groupscompatibility-levelreportingsql server

I have Availability Group with below config:

replica-01: SQL Server 2012 (primary)
replica-02: SQL Server 2012 (secondary synchronous)
replica-03: SQL Server 2016 (secondary asynchronous)

replica-01 and 02 are in on-premise data center
replica-03 is on Azure VM
(03 is synchronizing, no problems here)

When I try to use replica-03 as reporting read-only server, running "use MyDB" statement shows the following

Cannot open database 'TestDB' version 706. Upgrade the database to the latest version.

I tried to run ALTER DATABASE MyDB SET COMPATIBILITY_LEVEL = 130
But it shows error message:

ALTER DATABASE failed because a lock could not be placed on database

Tried to exclude MyDB from availability group, set compatibility level to 130, and include back to AG
But since database in NORECOVERY mode, it does not allow me to set compatibility level

If I restore database with recovery, I can set compatibility level to 130, but can't return database in norecovery mode, and can't add back to AG

What do you suggest on above ?

I need to keep primary SQL server replica as 2012 for now, and I need to make async replica (SQL server 2016) to be available for read-only access

Best Answer

What do you suggest on above ?

I need to keep primary SQL server replica as 2012 for now, and I need to make >async replica (SQL server 2016) to be available for read-only access

There is nothing you can do, this is a known item:

During a version upgrade, readable secondaries cannot be read after an upgrade of the readable secondary and before either the primary replica is failed over to an upgraded secondary or the primary replica is upgraded.

https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/upgrading-always-on-availability-group-replica-instances