I need to exit the SQL script without error if a certain condition is met. I read that 1 solution will be raiseerrorwith an error code parameter of 20+ and with log. But the limitation is that I can only do this as an administrator, and the connection to db will be canceled.
In addition, I tried to use GOTO and go to the end of the script, but it does not work, because I have several GOs in the middle of the script. Is there any other solution?
IF <some condition>
BEGIN
GOTO Finished;
END
GO
Finished:
SELECT 'Done'
Thank!
source
share