Question : High Insert/Update  time because of Trigger

Dear ALl,
           I have an Issue here.There is one Table used to record Transaction on all product transacted that day.
Also there are 2 triggers that is defined on the same table (one is INSERT and second is UPDATE).
I have come across a drastic difference on insertion/ updations time depeneding the the number involved
product on which invoice is made.
Example  : If i generate an invoice containing 6-50 product then it takes 2 seconds to save where as if generate
invoice on 100 products then it takes 30 minutes to save.

 Can you figure out where the issue lies.

 Also when i disable the trigger then invoice containing 100  products get saved in 3- 4 second .

 Feel free to take more inputs from myside regarding this problem.


Answer : High Insert/Update  time because of Trigger

The problem might be with creation of temp tables and the allocated size of temp db. Since you are not dropping the temp tables manually at the end of trigger, they might still hold space on tempdb. If there is no space on tempdb for creating more tables for insert on each row(remember SQL server supports only row level triggers), then the server waits for tempdb space to be freed unless you have specified infinite data file.

Add the following at the end of the

drop table #TempTempSkuTransaction;

Also check if you can de-allocate TempTable.

Random Solutions  
programming4us programming4us