日期:2014-05-19  浏览次数:20825 次

SQL Server不支持行触发,怎么办?
我用语句进行批量更新时,SQL   Server不支持行触发,对此问题,大家有没有好的方法实现功能。在线等待。。。。

------解决方案--------------------
那是你的觸發器寫得有問題
樓主,要不貼出來看看
------解决方案--------------------
江涛不是已经告诉你了吗?
----------------------------------------------
rockyljt(江濤) ( ) 信誉:100 Blog 加为好友 2007-5-17 16:14:56 得分: 0

你那樣寫的話,只能對更新一筆數據時有用
若是批量更新時就沒有了
-----------------------------------------------
Select @strPrepareCode=A.PrepareCode,@intNetID=A.NetID,@strOrderType=A.OrderType,
@strPreCode=A.PreCode,@SumNumber=Count(1)
From Inserted A,P_NETPrepare_Sub B
Where A.PrepareCode=B.PrepareCode
Group by A.PrepareCode,A.NetID,A.OrderType,A.PreCode
你的这种写法是不正确的,多行更新的时候就只会更新一条记录.
用游标改写:
declare cur_tmp cursor for
Select A.PrepareCode,A.NetID,A.OrderType,
A.PreCode,Count(1)
From Inserted A,P_NETPrepare_Sub B
Where A.PrepareCode=B.PrepareCode
Group by A.PrepareCode,A.NetID,A.OrderType,A.PreCode
open cur_tmp
fetch next from cur_tmp into @strPrepareCode,@intNetID,@strOrderType,@strPreCode,@SumNumber
while @@fetch_status=0
begin
--你的处理数据的代码
fetch next from cur_tmp into @strPrepareCode,@intNetID,@strOrderType,@strPreCode,@SumNumber
end
close cur_tmp
deallocate cur_tmp