How to insert record or redirect query when connection string using ApplicationIntent=ReadOnly in SQL Server

Niraj Sevalkar 21 Reputation points
2020-12-16T10:55:51.807+00:00

Hi Experts,

We have set up of always on for our SQL instances 2017 and we are trying to move our read only queries to secondary server we are using ApplicationIntent=ReadOnly to avoid burden on server , there are few issues with our existing code could you please advise on this.

Problem:

We are using secondary server for getting call for SSRS RDL for reporting and using ApplicationIntent=ReadOnly in connections string but there are few stored proc where we are using insert statement logging errors or steps of code.

since we are in read only connection string we are getting error of read only database. do we have any work around to overcome such scenario.

48706-error.png

Developer technologies Transact-SQL
SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Shashank Singh 6,251 Reputation points
    2020-12-16T14:08:05.04+00:00

    since we are in read only connection string we are getting error of read only database. do we have any work around to overcome such scenario.

    No you do not have any workaround, the database is in read-only mode which mean only read queries can run. You would have to remove the insert part and put it in other procedure which runs on primary replica

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.