ALTER      procedure sp_sdf
@i int
asprint @@trancountif @@trancount>0 ROLLBACK    --如果事物没有存在则回滚begin Transaction
select zz into #sd from table1
if @@error<>0
begin
goto Error_handlerendselect * from #sd where ssss=9 ---故意写错字段让他回滚
if @@error<>0
begin
goto Error_handler

end
drop table #sd
if @@error<>0
begin
goto Error_handler

endCommit Transaction 
select  iResult=1    --成功,返回1值
print @@trancount
return 0
Error_handler: 
BEGIN
        RollBack Transaction 
--select  iResult=0  --发生异常,错误回滚,返回0值
        return @@error
END/*为什么执行到select * from #sd where ssss=9 后他不回滚了,
出现
列名 'ssss' 无效。
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。
@@error后应该执行回滚超做的,为什么@@trancount还是=1,有谁知道原因的吗
*/