BEGIN TRY
EXEC BadInsert;
END TRY
BEGIN CATCH
IF XACT_STATE() <> 0 ROLLBACK TRAN
PRINT 'error ' + CAST(ERROR_NUMBER() AS VARCHAR(4))
PRINT 'severity '
+ CAST(ERROR_SEVERITY() AS VARCHAR(5))
PRINT 'state ' + CAST(ERROR_STATE() AS VARCHAR(5))
PRINT ERROR_MESSAGE()
PRINT 'procedure '
	+ CAST(ISNULL(ERROR_PROCEDURE(), 'BATCH')
	AS VARCHAR(5))
PRINT 'line ' + CAST(ERROR_LINE() as VARCHAR(5))
END CATCH
a
b
