I am working with a script that creates a SQL Agent job in SQL Server 2014. The job's last 2 steps are "Complete with Success" and "Complete with Failure". The script always warns of non-existent steps.
Warning: Non-existent step referenced by @on_fail_step_id.
Warning: Non-existent step referenced by @on_success_step_id.
Warning: Non-existent step referenced by @on_fail_step_id.
SET ANSI_WARNINGS OFF
has no effect on these as they are, I imagine, not ANSI warnings.
Is there a way to suppress these?
Best Answer
I was able to reproduce the issue. Problem is step 1 is refering to steps that are not created yet. Following code will generate the same error you are getting.
I commented out 4 lines on the 1st step. Added a section calling sp_update_jobstep. This code will not throw the error you are getting. I am only pasting modified code here.
Add this at the end of creating last step and before running sp_add_jobserver.