Hi, New to SQL. The below Code does what I want but just want to know if there is a better way to get the same results. When there is an Insert or update on the Sale PackingSlip Table Some Data has to be copied to another table (ItemTransations)There will be more than one line of date in an Insert or update.Ta Jorge ALTER TRIGGER [OMS].[UpdateSalePackingSlip] ON [OMS].[SalePackingSlip] AFTER INSERT,UPDATEAS BEGINSET NOCOUNT ON; IF Update(Quantity) or Update(LocationID) or Update(ItemID) begin Declare @TempTable Table ( PK int identity(1,1) not null Primary Key, Refance Int, LocationID Int, Qty Numeric(9,0), ItemID int) Declare @MaxRecords int, @RecordCount int Insert Into @TempTable (ItemID, Refance, LocationID,Qty) Select ItemID, ItemSaleLineID, LocationID, Quantity From Inserted Set @MaxRecords = (Select Max(PK) From @TempTable) Set @RecordCount = 1 Declare @ItemID Int, @Refance Int, @LocationID Int, @Qty Numeric(9,0) While @RecordCount <= @MaxRecords begin Select @Refance = Refance, @LocationID = LocationID, @Qty = Qty, @ItemID = ItemID From @TempTable Where PK = @RecordCount If Exists (Select RefanceID,ItemID,LocationID From IMS.ItemTransactions Where RefanceID = @Refance and ItemTransactionTypeID = 1) Begin Update IMS.ItemTransactions Set ItemID = @ItemID, Quantity = @Qty*-1, LocationID = @LocationID Where RefanceID = @Refance and ItemTransactionTypeID = 1 end Else Begin Insert Into IMS.ItemTransactions( ItemID, RefanceID, ItemTransactionTypeID, LocationID, Quantity) Values( @ItemID, @Refance, 1, @LocationID, @Qty*-1) end Set @RecordCount = @RecordCount + 1 end endEND