Created
March 28, 2016 13:09
-
-
Save imrexhuang/5734270e9f4ad68fdf61 to your computer and use it in GitHub Desktop.
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 / 0; | |
--RAISERROR(N'Message', 16, 1); | |
--儲存Error | |
SET @ErrorVar = @@ERROR | |
IF @ErrorVar <> 0 | |
BEGIN | |
--PRINT N'Error = ' + CAST(@ErrorVar AS NVARCHAR(8)); | |
PRINT @ErrorVar; | |
END | |
ELSE | |
BEGIN | |
PRINT '執行過程沒有發生錯誤!'+ CHAR(13)+'@ErrorVar:'+CAST(@ErrorVar AS NVARCHAR(8)); | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment