This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--參考 https://technet.microsoft.com/zh-tw/library/ms190193(v=sql.105).aspx | |
--宣告儲存Error的變數 | |
DECLARE @ErrorVar INT | |
--產生Error | |
SELECT 6 / 2; | |
--RAISERROR(N'Message', 16, 1); | |
--儲存Error | |
SET @ErrorVar = @@ERROR | |
IF @ErrorVar = 0 | |
BEGIN | |
PRINT '執行過程沒有發生錯誤!'+ CHAR(13)+'@ErrorVar:'+CAST(@ErrorVar AS NVARCHAR(8)); | |
END | |
IF @ErrorVar <> 0 | |
BEGIN | |
PRINT '執行過程發生錯誤!'+ CHAR(13)+'@ErrorVar:'+CAST(@ErrorVar AS NVARCHAR(8)); | |
END | |
沒有留言:
張貼留言