sp_add_job doesn''t seem to work as advertised

  • Has anyone successfully used msdb.dbo.sp_add_job to create a job with the @owner_login_name parameter?  It says you can do that in BOL, but it seems to just ignore the parameter and instead creates it with the current login name.

    There is no "i" in team, but idiot has two.
  • I was able to do so on my test server just now. Did the following:

    DECLARE @jobid uniqueidentifier

    EXEC msdb.dbo.sp_add_job @job_name = 'test', @owner_login_name = 'sa', @job_id = @jobid OUTPUT

    PRINT @jobid

    Also tried it with a Windows account and that was reflected correctly.

    K. Brian Kelley
    @kbriankelley

  • Dang.  I was hoping someone would come back with, "yep, that's a known bug".  That's how I call it, too.

    declare @ReturnCode int

    , @jobID uniqueidentifier

    EXECUTE @ReturnCode = msdb.dbo.sp_add_job 

      @job_id = @JobID OUTPUT

    , @job_name = 'NextTestJob'

    , @owner_login_name = 'IDBR_Admin'

    , @enabled = 1

    select suser_sname(owner_sid)

     from msdb.dbo.sysjobs where job_id = @JobID

    The select returns my domain login instead of 'IDBR_Admin'.  I also tried it with another domain login (besides mine) and it still returns mine.  Any ideas?

    Thanks, Dave

    There is no "i" in team, but idiot has two.

Viewing 3 posts - 1 through 2 (of 2 total)

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