Answer the question
In order to leave comments, you need to log in
How to learn to the trigger value of a field of a deleted line?
Such a task:
Create a trigger that will automatically increment or decrement [Number of Employees] in the [Departments] table when adding or deleting records in the [Employees] table.
Answer the question
In order to leave comments, you need to log in
CREATE TRIGGER sampleTrigger
ON database1.dbo.[СОТРУДНИКИ]
FOR DELETE
AS
UPDATE database1.dbo.[ОТДЕЛЫ]
SET [КОЛСОТР] -= 1
WHERE [КОДОТДЕЛА] = (SELECT deleted.[КОДОТДЕЛА] FROM deleted)
GO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question