请教一个触发器的问题,谢谢
我有一个表是这样的:   
 uid   score   pid    
 1   10   0    
 2   10   1    
 3   10   1        
 当我给一个记录更改值时,同时要触发另一个记录更改相应的值。例如我在第二条记录上给score加上2,它的值应该变成12,由于它管理的pid号是1,所以相应的uid号为1的记录也应该加上2.即:      
 uid   score   pid    
 1   12   0    
 2   12   1    
 3   10   1      
 如果再给uid=3的记录score+3,则最后的结果为      
 uid   score   pid    
 1   15   0    
 2   12   1    
 3   13   1      
 这个触发器应该如何写呢?请教大家了。谢谢      
------解决方案--------------------drop table 表 
 go 
 create table 表(uid int,score int,pid int) 
 insert into 表 
 select 1,10,0  
 union all select 2,10,1  
 union all select 3,10,1  
 go 
 create trigger tu_表 on 表 
 for update 
 as 
 if update(score) and exists(select 1 from inserted i,deleted d where i.uid=d.uid and isnull(i.score,0) <> isnull(d.score,0)) 
 begin 
 	update 表 
 	set score = 表.score + (i.score - d.score) 
 	from 表,inserted i,deleted d 
 	where 表.uid=i.pid and i.uid=d.uid 
 	and isnull(i.score,0) <> isnull(d.score,0)  
 end