I have a stored procedure that runs 1700 merge replication subscription jobs serially every night. After starting each job, it calls xp_sqlagent_enum_jobs in a loop with a 1 second delay to see if the job has finished before starting the next one. The problem is that the call sometimes takes up to 3 minutes to complete and it's causing the overall performance of the procedure to suffer terribly. Even on a good night, that call takes 30 seconds to complete every time.
I've also tried calling "sp_help_job @jobid = @jobid, @job_aspect='job' " and saving the results to a table to check the current status. It takes a similar amount of time to complete.
I've checked the msdb database for index fragmentation and found none.
Is there a better/faster way to check the status of a job? All I need to know about it is whether it's currently running or not.
The server in question is running SQL 2000.
Chuck