SET XACT_ABORT OFF
declare @myError int
BEGIN TRAN
INSERT INTO pubs..jobs VALUES('fix fonts1', 10, 20)
SET @myError = @@ERROR
if @myError <> 0 GOTO ErrorOccured
INSERT INTO pubs..jobs VALUES('add headlines2', 3, 20)
SET @myError = @@ERROR
if @myError <> 0 GOTO ErrorOccured
COMMIT TRAN
GOTO Done
ErrorOccured:
DECLARE @severity int
SELECT @severity = severity FROM master..sysmessages
WHERE error = @myError 
IF @@TRANCOUNT > 0 ROLLBACK TRAN
PRINT 'Error ' + 
CAST(@myError as VARCHAR(5)) + 
' occured with severity ' + 
CAST(@severity as varchar(3))
Done:
SELECT @@TRANCOUNT

select * from master..sysmessages
select * from pubs..jobs
