Possible Duplicate:
Read and Increment int value in SQL Server
I am currently working on "Double Entry Accounting" in relational database.
According to the article, it quotes
"The primary key or part of the primary key of the 'POSTING' table should be a system generated sequence number. It should also be generated in such a way that no gaps can appear in the sequence (through a transaction rolling back, for example). This is part of ensuring that no entries are ever deleted."
I am trying to find a way to achieve this goal. I cannot use the identity column because the transaction rollback, so my 'Posting' table has a column called seqNum which going to be used for this but how can I ensure the values in this column are in sequence. We have a lots of users that can be using our website at the same time.
Do I have to use table lock to ensure a sequence access to this table until the transaction is committed? But how?
I am currently using Microsoft Sql Server 2008.