High Availability Reversed - Force secondary unless failure

  • Hi

    I have sql2022 in H/A with a primary and a secondary server.

    My problem is that I have a query that I need to force it to run the secondary. But I need to point to the listener in case of failover, which is always pointed at the primary.

    Is there any kinda of logic or command I could add that forces the query to use secondary unless there is a failover - then run from primary.

    • This topic was modified 3 months, 1 week ago by krypto69.
  • First - the secondary must be configured for read-only or read-intent, and you must have Read-Only Routing defined for each node in the AG.

    If you have both of those, then add to the connection string 'ApplicationIntent=ReadOnly'.  This will cause the listener to redirect the connection to the secondary defined in the read only routing table.  If the secondary is not available, the connection will be routed to the primary.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply