SQLserver2008 存储过程对于事务的运用问题
有个存储过程中中有
--[dbo].[tfm_t_MonReceivablesInfo] --核销收款信息
DELETE from [tfm_t_MonReceivablesInfo] where MExpensesID=@MExpensesID
--[dbo].[tfm_t_MonAccessory]--核销附件
DELETE from [tfm_t_MonAccessory] where MExpensesID=@MExpensesID
--[dbo].[tfm_t_MonExpensesStore] --核销终端
DELETE from tfm_t_MonExpensesStore where MExpensesID=@MExpensesID
。。。。。。
连续删除几个表的操作。
用户操作数量一般在100人以上
有时会出现其中有一个表或者几个表没有删除成功数据。
问题:1.是因为并发吗?(不存在删除a表,不能再根据参数删除b表 的情况)
2.添加事务
begin transaction tr
begin try
。。。。。
。。。。。
commit transaction tr
end try
begin catch
rollback transaction tr
SET @msgtip = '事务执行错误!'
GOTO Result
end catch
是否能避免这种情况的发生?
3.事务的具体用处是哪些?