Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
分支到带标签的语句。
label : GOTO label
Transact-SQL 过程、触发器或批处理中的任何语句都可以带标签。标签名是一个有效标识符后跟一个冒号。在 GOTO 语句中不使用冒号。
如果嵌套复合语句,则只能转到 (GOTO) 当前复合语句及其任何祖先复合语句中的标签。而无法转到被嵌套在祖先语句内的其它复合语句中的标签。
无。
SQL/2008 服务商扩充。
以下 Transact-SQL 批处理在数据库服务器消息窗口中输出四次消息 "yes":
DECLARE @count SMALLINT SELECT @count = 1 restart: PRINT 'yes' SELECT @count = @count + 1 WHILE @count <=4 GOTO restart