Sql Server job – Cannot insert the value NULL into column ‘owner_sid’, table ‘msdb.dbo.sysjobs’

I needed to script out a Sql job one Sql server (server1) and use the same script to create the same job on a different Sql server machine(server2). So, I scripted out the job from Server1 and ran the same on the Server2 and got the below error :-

Cannot insert the value NULL into column ‘owner_sid’, table ‘msdb.dbo.sysjobs’

Looking at more closely on the script, I noticed that the the script I created from the job on the Server1 also has the login which I used to login to Server1. This login is different from the one I was using to run the script on server2. See the highlighted login in the below screenshot.

image

Once I changed the script to put the login I am using to run the script on server2, the script ran fine and the job got created in the Server2.

image

Advertisements

, ,

  1. #1 by Santhosh on July 23, 2014 - 3:06 am

    Thanks for this. It helped. When I scripted out a job and executed in other environment I got this error. Issue was even though the user name is same, I was using the old Domain inside the script.
    after correcting this, the script ran successfully.

  2. #2 by Jose on April 8, 2016 - 7:07 pm

    Right on the money, thanks

  3. #3 by greg on April 26, 2017 - 3:03 pm

    Worked for us as well! Thanks for great advice!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Random Thoughts

The World as I see it

Simple Programmer

Making The Complex Simple

Ionic Solutions

Random thoughts on software construction, design patterns and optimization.

Long (Way) Off

A tragic's view from the cricket hinterlands

%d bloggers like this: