Reputation: 1119
I have created a trigger, that should update a field with value from another field. the data is being pulled from two tables.
Table 1 Columns(myTable);
name|subject|forward|goalie|Id
Table 2 Columns(MyTable2);
team|
My Trigger
CREATE TRIGGER dbo.[TriggerName]
ON dbo.myTable
AFTER INSERT, UPDATE
AS BEGIN
UPDATE t SET Subject =
t.Name + ' - ' + c.team + ' - '+
CASE
WHEN t.new_forward = 1 THEN 'Forward,' ELSE ''
END +
..........
..........
..........
CASE
WHEN t.new_goalie = 1 THEN 'Goalie, ' ELSE ''
END
FROM dbo.myTable t
INNER JOIN dbo.myTable2 c
JOIN INSERTED i ON t.Id = i.Id
END
The error I get The multi-part identifier t.Id could not be found
What is wrong with my syntax?
Thanks
Upvotes: 0
Views: 44
Reputation: 1589
Per your own definition, the table myTable
doesn't have a field called Id
Table 1 Columns(myTable);
name|subject|forward|goalie
Without that field, your join of JOIN INSERTED i ON t.Id = i.Id
is referring to a column that doesn't exist.
Upvotes: 1