Hi @laroussi derbel ,
Did you want to create a trigger when all conditions are met or when either one condition is met?
Please also check if the similar thread SQL Server Trigger with multiple conditions could help you.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hello everyone ,
i have a question , i have a trigger that actually insert values from a table to a table every time that a conditon is meet
ALTER TRIGGER [dbo].[tinsertV1]
ON [dbo].[book1]
AFTER UPDATE
IF EXISTS (SELECT *
FROM inserted i
JOIN deleted d ON i.ConfigID = d.ConfigID
WHERE i.ConfigID = 251
AND d.Value = 0
AND i.Value = 1)
BEGIN
INSERT INTO OfenbuchVC1212_V10 ( Datum , Zeit, Temperatur , Oxidationszeit )
...
END
my question is , can i add another condition to this trigger ?
i tried this program but it didnt work
ALTER TRIGGER [dbo].[tinsertV1]
ON [dbo].[book1]
AFTER UPDATE
IF EXISTS (SELECT *
FROM inserted i
JOIN deleted d ON i.ConfigID = d.ConfigID
WHERE i.ConfigID = 251
AND d.Value = 0
AND i.Value = 1)
and EXISTS (SELECT *
FROM inserted i
JOIN deleted d ON i.ConfigID = d.ConfigID
WHERE i.ConfigID = 250
AND d.Value = 0
AND i.Value = 1)
BEGIN
INSERT INTO OfenbuchVC1212_V10 ( Datum , Zeit, Temperatur , Oxidationszeit )
...
END
Hi @laroussi derbel ,
Did you want to create a trigger when all conditions are met or when either one condition is met?
Please also check if the similar thread SQL Server Trigger with multiple conditions could help you.
Just to be clear.
A trigger can contain almost any valid TSQL commands. Any criteria you can think of you can do.
However, keep in mind a trigger runs after every UPDATE command. So the more complex your trigger, the slower the UPDATE will run.