I my db I have basically two indentical tables where one holds aggregates from the other table. They look like this:DECLARE @table table (UserID int, MarketID int, Price int, Volume int, Active tinyint)DECLARE @aggregate table (UserID int, MarketID int, Price int, Volume int)
A user can have several rows in @table with the same market and price but different volume so the volume is then aggregated and put in to @aggregate so that each user only has one row per price in a market (this is done for rapid reading purposes). So far everything works great and @aggregate is filled with data from a trigger. However, when a user deactivates all records for a price in @table, the corresponding row in @aggregate should be deleted because there is no data to support that price beeing there anymore. And the trigger naturally only aggregate the active prices omitting those that are not active instead of suming it to 0. @aggregate is read using WITH (NOLOCK) so I'm afraid deleting all rows for a market and inserting only the active ones again will cause empty markets on my website...does anybody have any tricks up their sleeve to work this out?--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand"