SQL Server相当于MySQL中的DECLARE CONTINUE HANDLER?

时间:2012-11-20 07:26:20

标签: mysql sql sql-server

我正在尝试执行mySql语句

"DECLARE DONE INT(1) default 0;    
DECLARE CONTINUE HANDLER FOR NOT FOUND SET DONE = 1;" 

在SQL Server 2005中

" DECLARE @DONE INT,    
DECLARE CONTINUE HANDLER FOR NOT FOUND SET DONE = 1" 

它给出了错误,如

"Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'CONTINUE'.
Msg 136, Level 15, State 1, Line 1
Cannot use a CONTINUE statement outside the scope of a WHILE statement."

MySQL DECLARE ... HANDLER command

1 个答案:

答案 0 :(得分:1)

SQL Server没有与上面链接的documentation中描述的处理程序机制直接等效。最明显的替代方案是: