Groups | Blog | Home
all groups > sql server replication > february 2007 >

sql server replication : Check Execution status when manually running Snapshot agents


Steve
2/21/2007 6:31:08 PM
I am working on a script to run in Query Analyzer to run all of my SnapShot
agents manually rather than wait for the schedule to do it. I am using
sp_start_job to run each agent such as:

exec msdb.dbo.sp_start_job @Job_Name='SQLSERVER-SomeSnapshotAgent-167'
waitfor delay '00:30:00' --some fixed time interval to try and have jobs not
run into each other
exec msdb.dbo.sp_start_job @Job_Name='SQLSERVER-AnotherSnapshotAgent-154'


If I put all of my Snapshot agent jobs in a script to run back to back, how
can I check for execution status so the next job does not run into the
previous agent already running?


Thanks,

Paul Ibison
2/22/2007 12:00:00 AM
Steve,
you can use the following rputine (modified slightly) to determine the job's
current status.
http://www.replicationanswers.com/Downloads/KillRunningJobs.txt
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com

Paul Ibison
2/22/2007 12:00:00 AM
Steve,
it'll be something like this - just replace the name with the name of the
snapshot agent:
select job_id FROM sysjobs

where name = 'UK-3XSW02J\PAULS2000INST-Pub1-2'

Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com



Steve
2/22/2007 5:58:03 AM
How do I obtain the Guid Job_id for the job name(s) that I am wanting to run?


Thank You

Steve



[quoted text, click to view]
AddThis Social Bookmark Button