Scenario:
I need a mechanism for obtaining an incremental value for each row in a table like so
SiteId NextTransactionID
1 1
2 10012
3 4
so on adding a transaction for site 2, transaction id should be incremented to 10013.
Dev team have coded this up, and unsurprisingly, if a site is busy with lots of transactions, then deadlocking occurs. (Stored proc is encrypted, but I'd bet it does a select with holdlock and then an update).
An identity column in transaction doesn't sort it, because the value must be incremental by site.
Any suggestions?
Am using SQL 2005
Start Free Trial