Microsoft SQL Server T-SQL 中是否有命令告诉脚本停止处理? 我想保留一个脚本用于存档目的,但我不希望任何人运行它。
最佳答案
另一种解决方案可能是使用 GOTO
语句更改脚本的执行流程...
DECLARE @RunScript bit;
SET @RunScript = 0;
IF @RunScript != 1
BEGIN
RAISERROR ('Raise Error does not stop processing, so we will call GOTO to skip over the script', 1, 1);
GOTO Skipper -- This will skip over the script and go to Skipper
END
PRINT 'This is where your working script can go';
PRINT 'This is where your working script can go';
PRINT 'This is where your working script can go';
PRINT 'This is where your working script can go';
Skipper: -- Don't do nuttin!
警告!上面的示例源 self 从 Merrill Aldrich 获得的示例。在你盲目地实现GOTO
语句之前,我建议你阅读他关于Flow control in T-SQL Scripts的教程。 .
关于sql - SQL Server 中的 T-SQL STOP 或 ABORT 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2028072/