Hello,
I'm somewhat of a SQL noob, trying to create a trigger that will update a field in table A whenever a new entry is added to table B.
I understand that joins are not allowed in updates as of SQL 2005. I'm getting the following error:
Msg 4104, Level 16, State 1, Procedure trackingno, Line 15
The multi-part identifier "UPS_IMPORT.BOX_ID" could not be bound so I'm using a where clause to compare fields.
Here is my SQL
ALTER TRIGGER [trackingno]
ON [dbo].[UPS_IMPORT]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
SET NOCOUNT ON;
UPDATE BOX set TRACKINGNO = (SELECT TRACKINGNO from UPS_IMPORT WHERE UPS_IMPORT.BOX_ID = BOX.BOX_ID) WHERE UPS_IMPORT.BOX_ID = BOX.BOX_ID
END
Any solutions or suggestions would be appreciated.
Open in new window