T-SQL STOP or ABORT command in SQL Server

后端 未结 9 573
轻奢々
轻奢々 2021-01-01 08:44

Is there a command in Microsoft SQL Server T-SQL to tell the script to stop processing? I have a script that I want to keep for archival purposes, but I don\'t want anyone t

9条回答
  •  孤独总比滥情好
    2021-01-01 09:06

    RAISERROR with severity 20 will report as error in Event Viewer.

    You can use SET PARSEONLY ON; (or NOEXEC). At the end of script use GO SET PARSEONLY OFF;

    SET PARSEONLY ON;
    -- statement between here will not run
    
    SELECT 'THIS WILL NOT EXEC';
    
    GO
    -- statement below here will run
    
    SET PARSEONLY OFF;
    

提交回复
热议问题