none
Trigger on Table - how to modify to update only one inserted record instead of whole table RRS feed

  • Question

  • Hi, I'm using the following trigger in order to update Alias description in my table

    ALTER TRIGGER [Planning].[UpdateFilterAliasDescription]
       ON  [Planning].[FiltersCatalog] 
       AFTER INSERT,UPDATE
    AS 
    BEGIN
    	-- SET NOCOUNT ON added to prevent extra result sets from
    	-- interfering with SELECT statements.
    	SET NOCOUNT ON;
    
        update Planning.FiltersCatalog set AliasDescription =
    	(Case when Leaf_name ='Org_Unit_Id' then 'Organisation Cost Centers'
    		  when Leaf_name ='F_Org_Unit_Id' then 'Organisation Cost Centers (Forecast purpose)'
    		  when Leaf_name = 'Cost_Categories' then 'Cost Categories'
    		  when Leaf_name = 'Financial_Elem_Id' then 'Planning Financial Positions'
    		  when Leaf_name = 'Working Version' then 'Working Version'
    		  when Leaf_name = 'Year' then 'Year'
    		  when Leaf_name = 'Consolidation' then 'Consolidation (Budget or Forecast)'
    		  when Leaf_name = 'Iso_Currency_Cd' then 'Currency'
    		  when Leaf_name = 'Customer_Ifrs_Id' then 'Segments'
    		  when Leaf_name = 'Main Version' then 'Main Version'
    		  when Leaf_name = 'Prod_Coa_Id' then 'Products'
    		  else 'Not Defined' end)
    END

    This trigger update all table records even when I insert only one record. How can I make this trigger working update only one inserted  record instead of whole table.

    Thanks a lot.

    Almir 

    Wednesday, June 29, 2016 11:10 AM

Answers