Wednesday, March 28, 2012

Problems with SQL-DMO.Job Script method

I am trying to create a vbs program to generate the script for SQL
Agent Jobs. In this program I am using the SQL-DMO objects for SQL
Server.
When the output is generated from the Job.Script method the job steps
are not in the correct order. They are ordered by step_name rather
than the step_id. Scripts generated from Enterprise Manager works
fine. It is just the ones from the DMO objects that get out of order.
Anybody have this problem as well?
Thanks in advance.
KeithProblem solved!
The msdb statistics were not updated and the query was using the
non-clustered index rather than the clustered index. The non-clustered
index was job_id, step_name. The clustered index is job_id , step_id.
Updated the statistics on msdb tables and it worked fine.

No comments:

Post a Comment