Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 updating date modified

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-19 : 08:56:36
willis writes "I added a column to a table called dateModified and a trigger to the table to update this column on an insertion or update. The problem is that when large amounts of records are inserted or updated in the database from an application the trigger does not fire for each update or insertion. I believe SQL is loading the data in batches (for performance I would guess) and executing the trigger only after a batch. I also beleive there is an system table that keeps track of the last batch. In this case I would need a cursor to loop through this table to update the dateModified column in the trigger. Isn't there a better way to do this rather than create a cursor on every update or insertion?

Thanks
Willis"

Nazim
A custom title

1408 Posts

Posted - 2001-12-19 : 09:41:06
On what event did u wrote the trigger .

i dont think the trigger will fire on a batch of records , t gets xecuted on each update or insert of a record. so therez no need for cursor here.


better put ur code here and someone will find out the bug in it




-------------------------
"Success is when Preparedness meets Opportunity"

Edited by - Nazim on 12/19/2001 09:53:36
Go to Top of Page

mfemenel
Professor Frink

1421 Posts

Posted - 2001-12-19 : 10:22:32
First, get a handle on exactly how your data is getting into the table. If the process is using BCP then triggers aren't going to help you anyway.

Second, I believe, although I'm not sure if this applies if the data is batched, you could update the table by joining the inserted table to your actual table, causing only those records which were added to be updated. The same process joining to the deleted table, would work for records that were updated.

Mike
"A program is a device used to convert data into error messages."
Go to Top of Page
   

- Advertisement -