| « Livet är ett mirakel - Emir Kusturica | Uppföljaren till Rocky filmerna » |
Handle Errors in SQL-Server - "Yukon"
TRY-CATCH in "Yukon"
Next version of SQL Server code named Yukon, introduces a new construct for error handling, as demonstrated by this example:
BEGIN TRY
SELECT convert(datetime, '2003121')
END TRY
BEGIN CATCH TRAN_ABORT
DECLARE @err int
SELECT @err = @@error
PRINT '@@error: ' + ltrim(str(@err))
END CATCH
The output is:
Server: Msg 241, Level 16, State 1, Line 2
Syntax error converting datetime from character string.
@@error: 241