Quantcast
Channel: SQL Server High Availability and Disaster Recovery forum
Viewing all articles
Browse latest Browse all 4532

Regarding SQL job in AlwayOn

$
0
0

Hi 

Based on below link i have created SQL Job on one of our SQL 2016.Everything is working fine.

http://blogs.microsoft.co.il/yaniv_etrogi/2016/12/11/alwayson-availability-groups-and-sql-server-jobs/

But in out put it is not displaying 

Stopped the job since this is not a Primary Replica

Date10/15/2019 12:05:41 PM
LogJob History (TEST-Index)

Step ID1
ServerQNV012C88
Job NameTEST-Index
Step NameAG-Check
Duration00:00:00
Sql Severity0
Sql Message ID14254
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted0

Message
Executed as user: SAFEWAY01\svcMsSqlserv. The step was cancelled (stopped) as the result of a stop job request.

-- Detect if this instance's role is a Primary Replica.
-- If this instance's role is NOT a Primary Replica stop the job so that it does not go on to the next job step
DECLARE @rc int;
EXEC @rc = master.dbo.fn_hadr_group_is_primary N'my-ag';

IF @rc = 0
BEGIN;
DECLARE @name sysname;
SELECT @name = (SELECT name FROM msdb.dbo.sysjobs WHERE job_id = CONVERT(uniqueidentifier, '$(ESCAPE_NONE(JOBID))'));

EXEC msdb.dbo.sp_stop_job @job_name = @name;
PRINT'Stopped the job since this is not a Primary Replica';
END;


Viewing all articles
Browse latest Browse all 4532

Trending Articles



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