相关文章推荐
帅呆的篮球  ·  子查詢 (SQL Server) - ...·  3 月前    · 
傻傻的馒头  ·  STRING_SPLIT ...·  3 月前    · 
紧张的铅笔  ·  GOTO (Transact-SQL) - ...·  3 月前    · 
刚毅的红金鱼  ·  CAST and CONVERT ...·  2 月前    · 
成熟的伏特加  ·  html,body{ width: ...·  1 年前    · 
文雅的登山鞋  ·  sha512解密工具-掘金·  2 年前    · 
性感的椅子  ·  gradle jacoco exclude ...·  2 年前    · 
慷慨大方的苹果  ·  MySQL - ON UPDATE ...·  2 年前    · 
如果 GOTO 语句指向该标签,则其为处理的起点。 标签必须符合 标识符 规则。 无论是否使用 GOTO 语句,标签均可作为注释方法使用。

Remarks

GOTO 可出现在条件控制流语句、语句块或过程中,但它不能跳转到该批以外的标签。 GOTO 分支可跳转到定义在 GOTO 之前或之后的标签。

Permissions

GOTO 语句的权限默认情况下授予任何有效用户。

Examples

以下示例显示如何将 GOTO 用作分支机制。

DECLARE @Counter int;  
SET @Counter = 1;  
WHILE @Counter < 10  
BEGIN   
    SELECT @Counter  
    SET @Counter = @Counter + 1  
    IF @Counter = 4 GOTO Branch_One --Jumps to the first branch.  
    IF @Counter = 5 GOTO Branch_Two  --This will never execute.  
Branch_One:  
    SELECT 'Jumping To Branch One.'  
    GOTO Branch_Three; --This will prevent Branch_Two from executing.  
Branch_Two:  
    SELECT 'Jumping To Branch Two.'  
Branch_Three:  
    SELECT 'Jumping To Branch Three.';  

See Also

控制流语言 (Transact-SQL)
BEGIN...END (Transact-SQL)
BREAK (Transact-SQL)
CONTINUE (Transact-SQL)
IF...ELSE (Transact-SQL)
WAITFOR (Transact-SQL)
WHILE (Transact-SQL)