I wrote a store procedure like the following

create procedure....as
begin
declare @e int
select @e = 0
begin trans
insert.....
if @@ERROR<>0
begin
@e = @@ERROR
print "...."
end
if @@ERROR<>0
begin
@e = @@ERROR
print "...."
end
if @e=0 then
commit transaction
else
rollback transaction
return 0


it is not working....when any error (especially wrong table name)...it is raising an error and no commit or rollback getting executed in the second statement....no other setting is made apart from the above code.