Sql-server – SELECT query in a SP in AlwaysOn Availability Group Read Only Routing

availability-groupsread-only-routingsql serversql-server-2016stored-procedures

There is a stored procedure which has select statement as well as insert and other statements. What will be the behaviour of the stored procedure in a Read Only Routing configured in AlwaysOn Availability Group?

Will the select statement go to the secondary server for reading and rest will be done on the primary server or since it is an inline statement in a stored procedure, that's why everything will take place on the primary itself.

I could not find any documentation regarding this, how will the select statement behave?

Best Answer

Read-only routing is per connection, not per batch or statement. Read-only intent is specified via the application connection string and the connection will be directed to a read-only replica (if possible) when the connection is established.