How can I rollback when my insert statement encounters "Attempt to insert duplicate row..." I see Command has been aborted, but my rollback statement does not get executed. In other words, how can I catch this error and perform rollback.

```
begin tran t1

insert into table1 (col1, col2 ) 
select col1, col2
from table2 

if @@error != 0 or @@transtate != 0
        begin
            rollback tran t1
            return
        end

```