我正在尝试执行以下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
最佳答案
SQL Server没有与上面documentation链接中描述的处理程序机制直接等效的功能。最明显的替代方法是:TRY...CATCH...
编写CLR stored procedure并使用.NET代码实现所需的任何处理代码; this question也有一些有用的信息
关于mysql - SQL Server是否等同于MySQL中的DECLARE CONTINUE HANDLER?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13468404/