解决方案: |
修改存储进程,在操作前先解锁,加上with(updlock)选项,操作正常。
存储进程165行到结尾,修改后语句如下:
BEGIN
SELECT fa_Cards.sCardNum,
SUM(fa_Cards_Detail.dblDecPreValueT) as dblDecPreValueT,
SUM(fa_Cards_Detail.dblRetDecPreValueT) as dblRetDecPreValueT
INTO #fa_Q_ZJQD_DY
FROM fa_Cards WITH(UPDLOCK) INNER JOIN fa_Cards_Detail ON fa_Cards.sCardID = fa_Cards_Detail.sCardID
WHERE (fa_Cards_Detail.sDeptNum LIKE @DeptCode + '%' AND fa_Cards.sTypeNum LIKE @TypeCode + '%')
AND fa_Cards.sCardID IN(SELECT Max(sCardID) FROM fa_Cards WITH(UPDLOCK)
WHERE ((fa_Cards.iTransPeriod)< @LoginPeriod or (fa_Cards.dTransDate Is Null)) AND ( (fa_Cards.dDisposeDate) is null or (fa_Cards.iDisposePeriod)< @LoginPeriod )
GROUP BY fa_Cards.sCardNum)
GROUP BY fa_Cards.sCardNum
-------------------- End -----------------
SELECT #fa_Q_ZJQD.sCardNum, #fa_Q_ZJQD.sAssetNum, #fa_Q_ZJQD.sAssetName,
Convert(decimal(18,2),([dblMonthValue_])-(case when dblDecPreValueT Is Null then 0 else dblDecPreValueT end) + (case when dblRetDecPreValueT Is Null then 0 else dblRetDecPreValueT end) - (case when dblDecPreValueTBegin Is Null then 0 else dblDecPreValueTBegin end)) AS dblMonthValue,
Convert(decimal(18,2),[dblDepr_]) AS dblDepr,
Convert(decimal(18,2),[dblDeprTotal_]) AS dblDeprTotal,
Convert(decimal(18,4),dblDeprRate_) AS dblDeprRate ,
Convert(decimal(18,4),dblPerDepr_) AS dblPerDepr,
Convert(decimal(18,3),dblWork_) AS dblWork,
Convert(decimal(18,3),dblWorkTotal_) AS dblWorkTotal
FROM #fa_Q_ZJQD left join #fa_Q_ZJQD_DY on #fa_Q_ZJQD.sCardNum = #fa_Q_ZJQD_DY.sCardNum
left join #fa_Q_ZJQD_Vouch on #fa_Q_ZJQD.sCardNum = #fa_Q_ZJQD_Vouch.sCardNum
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
|