CREATE TRIGGER [dbo].[RankingHeroPK]
ON [dbo].[Character]
after update
as
IF UPDATE(pkcount)
begin SET NOCOUNT ON;
Update [Character] set [Character].PkCountWebHero=PkCountWebHero+1,[Character].HeroDay=HeroDay+1,
[Character].HeroWeek=HeroWeek+1,[Character].HeroMonth=HeroMonth+1, pkcount=0
Where [Character].accountid=(SELECT accountid FROM Inserted)
and [Character].name=(SELECT name FROM Inserted) and [character].pkcount < 0
end
IF UPDATE(pkcount)
begin SET NOCOUNT ON;
Update [Character] set [Character].PkCountWeb=PkCountWeb+1,[Character].PKDay=PKDay+1,
[Character].PKWeek=PKWeek+1,[Character].PKMonth=PKMonth+1, pkcount=0
Where [Character].accountid=(SELECT accountid FROM Inserted)
and [Character].name=(SELECT name FROM Inserted) and [character].pkcount > 0
end