In SQL Server, you can use GOTO
to alter the flow of execution. You can use it to “jump” to another part in the T-SQL code.
The way it works is, you create a label, then you can use GOTO
to jump to that label. Any code between GOTO
and the label are skipped, and processing continues at the label.
GOTO
statements and labels can be used anywhere within a procedure, batch, or statement block. They can also be nested.