Hi,create procedure bat1asbeginset nocount onDeclare @sample table (t varchar(20))begin tran begin insert into @sample select 'stat1' select 1/0 --Divide by zero error encountered. insert into @sample select 'stat11' endrollback tranbegin tran begin insert into @sample select 'stat2' endcommit transelect * from @sampleset nocount offend
when I execute the stored procedure Exec bat1,the below output comes:-----------Msg 8134, Level 16, State 1, Procedure bat1, Line 12Divide by zero error encountered.t--------------------stat1stat11stat2
Since "Divide by zero error encountered" have encountered,how the rollbacked transaction ie stat1,stat11 value is getting stored in @sample table variableActually it should get rollback, and the stat2 alone need to be stored na.please correct if iam wrong