0

getting error:

"The target database ('MyDB') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online."

in the SQL error logs with no information who is trying to log in.

This is on SQL 2017 version 14.0.3026.27 with Always On High Availability

Tomasz
  • 186
  • 2
  • 13

2 Answers2

1

The question is not clear, but I am going to assume you attempting to perform a write on a read only database.

The error message you are getting is telling you that the database you are trying to connect to is in an availability group and is currently only accessible for connections with the application intent set to read only. This means that you cannot connect to the database with the application intent set to read write.

To fix this, you need to make sure that the application intent is set to read only on your connection string. You can do this by adding the following property to your connection string:

ApplicationIntent=ReadOnly
Koketso M
  • 21
  • 5
0

So on the SQL server, I was able to go to the "Event Viewer -> Windows Logs -> Application" and was able to match the event time with my time stamp in the SQL error log. Then i was able to find the user that was causing the error. Since we have a newly introduced AlwaysOn environment we went through his options to make sure it was set up correctly, that didn't help.

The issue was that he was on an old verision of SSMS that when he tried to connect seemed to cause the error. We updated his SSMS to latest version and it stopped.

Tomasz
  • 186
  • 2
  • 13