use pubs;
go
if exists(select name from sysobjects 
   where name='ReCalculateCost' and type='TR')
drop trigger ReCalculateCost
go
create trigger ReCalculateCost
on Sbill
for update,insert,delete
as
begin
   update Ssum
   set Scost=(select sum(Samount*price) from Sbill
   where Ssum.Scode=Scode)
end