T-SQL: only run job on primary node

Bschelst/ August 26, 2019/ SQL-Server/ 0 comments

If sys.fn_hadr_is_primary_replica ( 'CC_DLL' ) <> 1  
BEGIN 
    -- This is not the primary replica, exit without error. 
	 print 'Secondary node'
END 
-- This is the primary replica, continue to run the job... 
else
begin
  YOURACTIONS
end
Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*