I found this question trying to reorder the steps without clearing them and re-adding them.
To solve this problem, I have a three-step process: (Assuming that only one step has failed or that all existing steps are in alpha order)
1) If necessary, delete the step you want to reorder. (You should use select for msdb.dbo.sysjobsteps if you need any existing values)
EXEC msdb.dbo.sp_delete_jobstep @job_id = @YOURJOBID, @step_id = @OUTOFORDERSTEPID
2) Use the comparison to get the position your new move should be.
@newStepPosition = SELECT MIN(step_id) FROM msdb.dbo.sysjobsteps WHERE job_id = @YOURJOBID AND step_name > N'YOURNEWSTEPNAME'
3) Just add a task step by specifying a position. All existing steps will be mixed. for example, an insert of 3 will squeeze from 3 to 4, from 4 to 5, etc.
EXEC msdb.dbo.sp_add_jobstep @ job_id=@YOURJOBID , @step_name=N'YOURNEWSTEPNAME', @ step_id=@newStepPosition , etc...
Tested with MS SQL Server 2008 R2. Hope this helps someone else take a look at this.
source share