In this post explains how to use the GOTO statement in SQL Server (Transact-SQL) with syntax and examples.
The GOTO statement causes the code to branch to the label after the GOTO statement.
The syntax for the GOTO statement in SQL Server (Transact-SQL) consists of two parts - the GOTO statement and the Label Declaration:
The GOTO statement consists of the GOTO keyword, followed by a label_name.
The Label Declaration consists of the label_name, followed by at least one statement to execute.
Let's look at how to use the GOTO statement in SQL Server (Transact-SQL).
For example:
In this GOTO example, we have created one GOTO statements called AODBA. If @site_value equals 2, then the code will branch to the label called AODBA.