当前位置: 代码迷 >> Sql Server >> mssql触发怎么执行全部,现在只执行最后一条
  详细解决方案

mssql触发怎么执行全部,现在只执行最后一条

热度:1   发布时间:2016-04-24 21:18:55.0
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这两个表去更新数据的
  相关解决方案