New answers tagged

0

I have working SQL to determine which machine is the PRIMARY or SECONDARY server and to use within the Stored Procedure scheduled to run on both machines SQL: select ars.role_desc,ag.name,ars.is_local from sys.dm_hadr_availability_replica_states ars inner join sys.availability_groups ag on ars.group_id = ag.group_id NOTE: I was expecting the ...


-1

Another way is to insert a step in each job, which should run first, with the following code: IF (SELECT ars.role_desc FROM sys.dm_hadr_availability_replica_states ars INNER JOIN sys.availability_groups ag ON ars.group_id = ag.group_id AND ars.is_local = 1) <> 'PRIMARY' BEGIN --We're on the secondary node, throw an error THROW ...



Top 50 recent answers are included