mike

mike

  • NA
  • 23
  • 5.2k

Sql Trigger - multi-part identifier could not be bound

Jun 9 2016 1:12 AM
I'm trying to insert a QuoteNumber from a table called AccountInfo into a table call ShippingInfo where the columns ShippingIdentity match, but I keep getting this error when I try to run this code. The line that throws the error is: inner join inserted on ShippingInfo.ShippingIdentity = a.ShippingIdentity. Can someone please  tell me why? Thanks for any help.
 
ALTER TRIGGER InsertQuoteNumber
ON AccountInfo
FOR INSERT
AS
BEGIN
INSERT INTO ShippingInfo (QuoteNumber)
SELECT a.QuoteNumber
FROM INSERTED as a
inner join inserted on ShippingInfo.ShippingIdentity = a.ShippingIdentity
update ShippingInfo set QuoteNumber = i.QuoteNumber
from ShippingInfo s
inner join inserted i on s.ShippingIdentity = i.ShippingIdentity
END
 

Answers (4)