SQL Server trigger (update or insert with inner join problem)
-
30-10-2019 - |
Question
ALTER TRIGGER [dbo].[killertrigg]
ON [dbo].[tbl_pvporderview]
AFTER UPDATE
AS
IF (UPDATE([Kill]))
BEGIN
SET NOCOUNT ON;
INSERT killer(serial,[Kill])
SELECT i.serial,i.[Kill] FROM inserted AS i
INNER JOIN deleted AS d
ON i.serial = d.serial
AND i.[Kill] <> d.[Kill] AND i.[Kill] > 0;
END
However how would I go if I would want it to update if the serial already exist in the killer
table. Could do update first and if it returns rowcount 0/null then do insert but I got stuck WHERE - since I can't use i.serial = d.serial
to compare there.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange