I have a deal and transaction table, where the deal table has an aggregated column, 'TotalSales', which is simply a count of transactions per deal.
With the following command, is there ever a chance the transaction row count and total sales count would not be in sync (not including deleting rows)? Does the default isolation level work for this? We have many users making purchases at potentially the same time, so I'm trying to figure out the best way to handle this.
BEGIN TRANSACTION
INSERT INTO [transaction] ...
UPDATE deal
SET TotalSales = (select count(*) from [transaction] where dealid = @dealId)
WHERE dealId = @dealId
COMMIT TRANSACTION