Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is it possible to conditionally force script execution to end -AND- be treated as an error?
For example, if a query or stored procedure doesn't return any results I would like to end the script execution as an error. I know I can use EXIT SCRIPT but this is treated as a graeful script completion and therefore can't be used to send a failure notification from Publisher et al. unless I am missing something.
Anybody doing anything like this today or have ideas?
Thanks -Isaiah
Hi Erich,
Facing the same challenge as Isaiah. I have set up ErrorMode = 0 in my script, so it continues if an error is Found. However, I also want to make the automated load (via tasks) to fail if I tried more than 3 times.
I tried using your non-elegant solution, but I still get the 'Success' status in the Task view, when in reality the SQL query failed.
This is my code. Any suggestions?
For vMaxRetries = 1 to 3 //Counter to ensure an SQL query is re-executed in case of a failure. Maximum 3 times per query
...
SQL Query Goes Here
...
If (ScriptError = 0) then // If I get any type of error, then try again. If not, exit the loop (for).
TRACE No error in SQL Query;
exit for
else
set ScriptError = 0;
endif
Next vMaxRetries
// Exit script if the above query tried & failed more than 3 times.
if vMaxRetries>3 then
fsadfasdf;
exit Script
endif
Thanks,
Steve.