当前位置: 代码迷 >> Sql Server >> sql事物,该怎么处理
  详细解决方案

sql事物,该怎么处理

热度:62   发布时间:2016-04-27 13:35:28.0
sql事物
现要往3张表插入数据,想使用事物,该怎么写??
我传递的参是model

------解决方案--------------------


SQL code
begin trybegin traninsert into ainsert into binsert into bif xact_state() =1commit tranelserollback tranend end trybegin catchif xact_state()<>0rollback tranend catch
------解决方案--------------------
探讨

引用:
SQL code

begin try
begin tran
insert into a
insert into b
insert into b
if xact_state() =1
commit tran
else
rollback tran
end
end try
begin catch
if xact_state()<>0……

------解决方案--------------------
你这个问题可能不是提在SQL 区吧 。 你用的是什么?C#? Java? 还是其它什么 你想问的是这个吧。。。
  相关解决方案