Branches to a user-defined label.
label: goto label
Shows the use of a label called restart:
declare @count smallint select @count = 1 restart: print "yes" select @count = @count + 1 while @count <=4 goto restart
The label name must conform to the rules for identifiers and must be followed by a colon (:) when it is declared. It is not followed by a colon when it is used with goto.
Make the goto dependent on an if or while test, or some other condition, to avoid an endless loop between goto and the label.
ANSI SQL – Compliance level: Transact-SQL extension.
goto permission defaults to all users. No permission is required to use it.