日期:2014-05-18  浏览次数:20389 次

sql 触发器简单问题
判断 a是否=36 如果=36 就更新字段为50 我下边写的为啥不行啊?请高手指点下,谢谢了
create trigger [名字] on [dbo].[表] 
for insert,update 
as
if update(字段)
Update [表] set [表].字段=50 where exists(select * from inserted where inserted.名字=[表].名字 and inserted.条件=36) 


------解决方案--------------------
SQL code


Update [表] set [表].字段=50 
from [表] a inner join inserted b on inserted.名字=[表].名字 and inserted.条件=36

------解决方案--------------------
SQL code
create trigger [pkcount] on [dbo].[Character]  
for insert,update  
as
begin  
Update [Character] set [Character].pkcount=50  
from [Character]  inner join inserted b on b.name=[Character].name and inserted.mapnumber=36