Reputation: 11019
If I have a SQL Server Trigger can I execute different update statements depending on the value of inserted/updated record?
IF inserted.Make = 'FORD'
BEGIN
UPDATE that depends on Ford
END
ELSE
BEGIN
UPDATE that depends on other Make
END
I thought this was correct but I am getting The multi-part identifier "inserted.Make" could not be bound
.
Upvotes: 2
Views: 6034
Reputation: 339
This solution is available at this link also.
CREATE TRIGGER
[dbo].[SystemParameterInsertUpdate]
ON
[dbo].[SystemParameter]
FOR INSERT, UPDATE
AS
BEGIN
SET NOCOUNT ON
If (SELECT Attribute FROM INSERTED) LIKE 'NoHist_%'
Begin
Return
End
INSERT INTO SystemParameterHistory
(
Attribute,
ParameterValue,
ParameterDescription,
ChangeDate
)
SELECT
Attribute,
ParameterValue,
ParameterDescription,
ChangeDate
FROM Inserted AS I
END
Upvotes: 3