4 responses

  1. Stuart Davis
    2020-08-11

    Why do you need all this cursor gubbins? you can just concatenate all the suspended databases into a single string!

    select @sql += ‘alter database [‘ + Db_Name(database_id) + ‘] set hadr resume; ‘
    from sys.dm_hadr_database_replica_states drs
    join sys.availability_replicas ar on ar.replica_id=drs.replica_id
    where ar.replica_server_name=@@ServerName and drs.is_suspended=1

    Reply

  2. Trev
    2021-02-09

    In response to the above comment, I get that you can build the query dynamically, but then how would you automate the execution?

    Reply

    • Wayne Sheffield
      2021-03-08

      You run the dynamically created query with the EXECUTE (@SQLCMD) statement within the job step.

      Reply

Leave a Reply to let me know how you liked this post

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top
mobile desktop