Help!!!!!!!!!

  • Hi,

    After running my code, the results are stored in one final table, so this table holds all data that I need. The problem is that I have one table in my database that has variables on it, which I constantly change. Those changes I need to be reflected on the previews results stored in my final table. Something like, using Excel I have one table filled with numbers that depend on one variable. When I change this variable all my numbers on the table are recalculated. This is what I need to do with my final table.

    Can someone help me????

  • Create an update trigger on your table holding variable data. This trigger should update values in your final table.

     

  • Thanks Mark, but I do not know how to do a trigger, could you guide me ????

    Thanks for the help.

  • Generally, the skeleton for your trigger will look like this:

    create trigger my_trigger

       on  my_master_table

       after update

    as

    declare

    @id  int,

    @val int

       

        select

            @id = id,

            @val = col_with_variable_value

        from inserted

        update my_final_table

        set final_result_col = @val * 2 -- put your calculations here

        where id = @id

    go

    Triggers operate with two internal system tables: inserted and deleted. Whenever you update your record, existing value is recorded into deleted table and the new record is recorded into inserted table. You can manipulate these two tables just like regular database tables.

     

  • Thank you Mark, I really appreciated.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply