Have a Rebate table which holds 2 types of records. Code type 1 which is a customer_no and item_no comboCode Type 3 which is a Customer_type and item_no comboWhen an order is entered have a trigger that reads the rebate table and if a match is found write the info that is in the Rebate table to an OrderRebate Table. It is possible there will be code type 1 and 3 that will match a certain customer number. But I want it to check for a code type 1 first, then if code type 1 does not exist then check for code type 3 and use it. So right now if both exist both get written. ALTER TRIGGER [updateOrderRebatebycusttype] ON [dbo].[oeordlin_sql] AFTER INSERTAS--This insert statement looks for matching records in the Rebate Table--It looks for customer type and item_no combinations or price Code type 3.--If a match is found it writes a record to the OrderRebate table.begininsert into OrderRebate(ord_type,ord_no,line_seq_no,item_no,qty_ordered,qty_to_ship,cus_no,a4ID,AccountTypeCode,price,rebate_pct,cd_tp)select inserted.ord_type,inserted.ord_no,inserted.line_seq_no,inserted.item_no,inserted.qty_ordered,inserted.qty_to_ship,inserted.cus_no,inserted.ID,cicmpy.AccountTypeCode,rebate.price,rebate.rebate_pct,rebate.cd_tpfrom inserted INNER JOIN cicmpy ON inserted.cus_no = cicmpy.debcode INNER join rebate on cicmpy.AccountTypeCode = Rebate.cd_tp_3_cus_type AND inserted.item_no = Rebate.item_nowhere cicmpy.AccountTypeCode = Rebate.cd_tp_3_cus_type AND inserted.item_no = Rebate.item_noend--This insert statement looks for matching records in the Rebate Table--It looks for customer number and item_no combinations or price Code type 1.--If a match is found it writes a record to the OrderRebate table.begininsert into OrderRebate(ord_type,ord_no,line_seq_no,item_no,qty_ordered,qty_to_ship,cus_no,a4ID,AccountTypeCode,price,rebate_pct,cd_tp)select inserted.ord_type,inserted.ord_no,inserted.line_seq_no,inserted.item_no,inserted.qty_ordered,inserted.qty_to_ship,inserted.cus_no,inserted.ID,cicmpy.AccountTypeCode,rebate.price,rebate.rebate_pct,rebate.cd_tpfrom inserted INNER JOIN cicmpy ON inserted.cus_no = cicmpy.debcode INNER join rebate on inserted.item_no = Rebate.item_no and inserted.cus_no = Rebate.cd_tp_1_cus_no where inserted.item_no = Rebate.item_no and inserted.cus_no = Rebate.cd_tp_1_cus_no end--This update statement calculates the rebate amount and extended rebate amt-- and updates the orderrebate table with these amounts for price code type 3 records-- and writes the literal 'Rebate' to freefield3 in the orderrebate table. freefield3 will help-- determine which records are rebate records that get inserted into the gbkmut table.beginupdate OrderRebateset rebate_amt = (rebate.price*(.01*rebate.rebate_pct)),ext_rebate = round((rebate.price*(.01*rebate.rebate_pct)*inserted.qty_to_ship),2),freefield3 = 'Rebate'from inserted INNER JOIN cicmpy ON inserted.cus_no = cicmpy.debcode INNER join rebate on cicmpy.AccountTypeCode = Rebate.cd_tp_3_cus_type AND inserted.item_no = Rebate.item_nowhere inserted.ord_type = OrderRebate.ord_type and inserted.ord_no = OrderRebate.ord_no and inserted.line_seq_no = OrderRebate.line_seq_noend--This update statement calculates the rebate amount and extended rebate amt-- and updates the orderrebate table with these amounts for price code type 1 records-- and writes the literal 'Rebate' to freefield3 in the orderrebate table. freefield3 will help-- determine which records are rebate records that get inserted into the gbkmut table.beginupdate OrderRebateset rebate_amt = (rebate.price*(.01*rebate.rebate_pct)),ext_rebate = Round((rebate.price*(.01*rebate.rebate_pct)*inserted.qty_to_ship),2),freefield3 = 'Rebate'from inserted INNER JOIN rebate on inserted.cus_no = Rebate.cd_tp_1_cus_no AND inserted.item_no = Rebate.item_nowhere inserted.ord_type = OrderRebate.ord_type and inserted.ord_no = OrderRebate.ord_no and inserted.line_seq_no = OrderRebate.line_seq_noend