create table Tg1
(
data int
)
create table Tg2
(
data int
)


Create trigger tg1_i ON  Tg1 FOR INSERT
AS
RAISERROR('some error', 16, 1)

SELECT * from tg2


BEGIN TRY
BEGIN TRAN
DECLARE @e int
INSERT INTO Tg1 VALUES (2)
SET @e = @@ERROR
PRINT 'got here' + CAST(@e as char(10))
SELECT '==' + CAST(@e as CHAR(10))
INSERT INTO Tg2 VALUES (1)
select @@trancount

COMMIT TRAN

END TRY
BEGIN CATCH
SELECT XACT_STATE()
END CATCH
ROLLBACK TRAN

