DECLARE @myError INT
BEGIN TRAN
INSERT INTO pubs..jobs 
	VALUES('fix fonts', 10, 20)
SET @myError = @@ERROR
IF @myError <> 0 GOTO ErrorOccured
INSERT INTO pubs..jobs
	VALUES('add headlines', 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:
a
b
c
d
