Quantcast
Viewing latest article 8
Browse Latest Browse All 11

AlwaysON job active-Passive

Create a first step in your SQL Agent job which runs this:

DECLARE @result INT;

SET @result = (select sys.fn_hadr_is_primary_replica ( 'your datbase name' ) )

IF @result = 0
	RAISERROR('Server not primary for database',16,0);

And in Advanced properties set "On failure action:" to "Quit the job reporting success".

Then the job will only run on the primary server.

Hello,

i tested it and works well. I put that piece of code before my script. It will work with all kind of script?

Thanks again


Viewing latest article 8
Browse Latest Browse All 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>