How to add go to next step in sql job via code.greenspun.com : LUSENET : SQL Server Database Administration : One Thread
I am trying to put a condition in the first step of my job to look for a file. If the file exist go to next step, if not quit the job. In VB i write to open the file as a step. When i deleted that file still the job was successfull saying 'The step didnot generate any output. The step succeeded'. I will apprecite your help.
-- Anonymous, March 16, 2001
A job or DTS package can be set up so that the next action or step performed can be different depending on whether the current job step succeeds or fails. This is determined by the return code from the job step. The return code values are 0 (for success) or 1 (for failure).
Thus, all you have to do is set up the job step that looks for the file to return either 0 or 1 depending on whether the file exists or not. The easiest way to do this is with an xp_cmdshell command to do a dir (directory command) for the file you are looking for. If you find the file, the result value of the xp_cmdshell command will be 0 (success). If the file is not found the result value will be 1 (failure).
Hope this helps,
-- Anonymous, March 19, 2001