Losing DKP through Loot Addition
CREATE TRIGGER [dbo].[tss_Loots_INSERT]
ON [dbo].[tss_Loots]
FOR INSERT
AS
BEGIN
SET NOCOUNT ON;
IF NOT EXISTS (SELECT * FROM inserted)
RETURN;
/*
When a Loot is added, debit the LootValue from the Player.
*/
UPDATE tss_Players
SET tss_Players.SpentDKP = tss_Players.SpentDKP + tss_Loots.LootValue,
tss_Players.SavedDKP = tss_Players.SavedDKP - tss_Loots.LootValue
FROM inserted
INNER JOIN tss_Loots ON inserted.LootID = tss_Loots.LootID
WHERE (tss_Players.PlayerID = inserted.PlayerID);
END