日期:2014-05-17  浏览次数:20736 次

mssql触发如何执行全部,现在只执行最后一条

CREATE TRIGGER TCMap ON dbo.tblGameID1
for update AS
if update(Map)
begin
declare @m int
declare @s int
declare @i varchar(14)
select @i=i from news
select @s=s,@m=m from news where i = @i
if (@s>1000 AND @m=2)  
begin
update news set t = 21,c = 100,y=100 where i = @i
return
end
end

------解决方案--------------------
select @i=i from news 这个地方开始用cursor
------解决方案--------------------
CREATE TRIGGER TCMap ON dbo.tblGameID1
for update AS
if update(Map)
begin
update news set t = 21,c = 100,y=100 where s>1000 and m=2
end
------解决方案--------------------
不明白楼的真正意图,可以借助Inserted、Deleted这两个表去更新数据的