mike

mike

  • NA
  • 23
  • 4.9k

My trigger is not insert value into correct row

Jun 9 2016 12:23 PM
hello,
I'm trying to write a trigger that get a QuoteNumber from table 1 and insert it into table 2 where ShippingIdentity matches the records in both tables. The problem is the QuoteNumber is being inserted into it's own row(record) Can anyone please let me know why? Thanks.
ALTER TRIGGER InsertQuoteNumber
ON AccountInfo
FOR INSERT
AS
BEGIN
INSERT INTO ShippingInfo (QuoteNumber)
SELECT a.QuoteNumber
FROM AccountInfo a
inner join inserted i on a.ShippingIdentity = i.ShippingIdentity
END

Answers (1)