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.
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.
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.
Right on the money, thanks
Worked for us as well! Thanks for great advice!
Thanks for this.. It helped me resolve the issue in DR process..
Thanks your suggestions. it worked for me also.
It help to me ! Thanks. Boris