I got this error when doing the following. I did right-click ‘Create Job as” then “Create to” a new query window. I was scripting 3 SQL agent jobs, then tried to combine them into one script.
I was trying to build my script without any “GO” commands, so I could have some variables at the top used throughout as parameters.
It was critical to reset these variables before each call to sp_add_job:
SET @ReturnCode = null
SET @jobID = null
The other “hits” I found when googling were totally off target of my solution above. I’m using SQL 2005, which seems to have an “originating_server_id” instead of an “originating_server” in the sysjobs table.
Hope this helps someone!
Filed under: SQL