onsdag 10 juni 2009

Howto make an if statement in a job step in MSSQL

I ran into a little problem where I wanted to check a flag in a table to see if the sql job should be run or not.

I'm not sure if it's the right way or the nicest way to do this, but it works.

In the first step do:
if (SELECT count(*) FROM update WHERE ) = 0
begin
RAISERROR( 'Not ready to update.' , 16, 1 )
end

Set the On success to Goto next step (as default) to proceed with following job steps. You could set the On failure to Quit with success to avoid the errors in the history since it's an expected error that is raised.

Inga kommentarer:

Skicka en kommentar