DMO JOBs Script method differs from EM Generate Script

  • I want to generate scripts for my jobs. I've found a couple of differences between using EM to Generate Script and DMO.

    Using EM I get :

      -- Add the Target Servers

      EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name = N'(local)'

    Using DMO Script method I get :

     execute @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name = N'uksedb02'

    I would like the '(local)'  version to be generated by the DMO script. Can this be achieved ?

    Secondly, the DMO script method generates an sp_add_category command without specifying '@name ='  before the name parameter and subsequently fails to run. The EM version is ok.

    I thought EM utilised the DMO to do its stuff.

    I'm using the method command :

    Jobserver.Jobs(' 1 ').Script(68,"script_file.sq")

    Rick.

  • I have never done this via DMO however, just from looking at the information provided I don't think that DMO is smart enough to realize that "I" am (local)....



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • I'm not really sure what you're asking here, but I think you're getting a bit confused about DMO.

    Your scripts are not running DMO, but both are running SQL sp's.

    Paul R Williams.

  • Paul, I think you are getting confused. I have only showed a snippet of one script which shows the DMO method I am using  

    Jobserver.Jobs(' 1 ').Script(68,"script_file.sq")

    Admittedly I am using the SP_OACreate ..etc procedures to execute the methods but I hadn't shown that, could have used vbs just as easily.

    The other stuff is demonstrating the output produced and how it differs when run from EM and from DMO directly.

    I still haven't sorted it out so any solutions are still welcomed.

    Rick.

  • Ok, forgive me, but I am still not entirely sure what the question is.

    In terms of DMO itself, with regard to the jobs, if it needs to use local as the target server, can you not use the ApplyToTargetServer Method of the Job object.

    Is this what you are asking ?

    Paul R Williams.

  • What I'm asking is how to get the output from jobserver.jobs.script method to produce the same/similar script to that generated by EM for a job. The bit that differs is where it generates the sp_add_jobserver text, the EM output has 'local' for the server name but the DMO output has the actual name of the server. I want the DMO script to also produce a script with 'local' i.e.  @server_name = N'(local)'

    I'm not creating or running jobs, just trying to automate script generation.

    Hope this clarifies.

    I'm not sure but I don't think 'ApplyToTargetServer Method of the Job object' is relevant to what I am trying to achieve. As I'm not actually applying or running jobs as part of this exercise.

    Rick.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply