这个存储过程从语法上会造成死锁?
CREATE PROCEDURE [dbo].aspnet_Vstock_Order_UserReset
@UserId uniqueidentifier,
@fMoney decimal(38,5),
@ErrorStr varchar(100) out
AS
BEGIN
declare @iError int
select @ErrorStr = ''
select @iError = 0
set xact_abort on
begin tran
delete from dbo.aspnet_Vstock_BuyOrder where UserId = @UserId
select @iError = @iError + @@Error
delete from dbo.aspnet_Vstock_Deal where UserId = @UserId
select @iError = @iError + @@Error
delete from dbo.aspnet_Vstock_DealHistory where UserId = @UserId
select @iError = @iError + @@Error
delete from dbo.aspnet_Vstock_SellOrder where UserId = @UserId
select @iError = @iError + @@Error
Update dbo.aspnet_Users set Vstock_TotalMoney = @fMoney where UserId = @UserId
select @iError = @iError + @@Error
if @iError = 0
begin
commit
print '--------001@\r\n'
end
else
begin
rollback
print '--------001*\r\n'
end
RETURN 0
END
GO
------解决方案--------------------
set xact_abort on 这个已经提示回滚了。
这几张表对应@userid的数据是否很多啊? 另外,LZ数据库的隔离级别是?
数据多的话,有可能等待别人释放资源。当然得看隔离级别是否为已提交读。