Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running jobs against replica databases

Status
Not open for further replies.

niall5098

IS-IT--Management
Jun 2, 2005
114
0
0
IE
HI All,

i have a job that runs a number of ssis packages. at the moment it runs against the primary database however i want to run it against the read only db. the setup is sql server 2012 with always on. the connection string for the package is the listener so i need to add a step to force the job to check if its primary or secondary and then run the next step.

what i was thinking was a piece of sql like so:

DECLARE @preferredReplica int


SET @preferredReplica = (SELECT [master].sys.fn_hadr_backup_is_preferred_replica('DBNAME'))

IF (@preferredReplica = 1)
Begin
go to step 2.

question is how do i programmatically get the step to the next step?

so something like

IF (@preferredReplica = 1)
Begin
run package or don't run package

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top