Use an identity column. Procs which do a MAX on a table arent safe per se (only with a serialized transaction, which is slow) and also leave gaps: you HAVE TO discard a value retrieved if the transaction failed, you can't re-use a value in that case. So the 'next in line' will never be 100% the next in line, it might be thread A (a website is multi-threaded) retrieves 10, thread B retrieves then thus 11, the transaction of A fails, and you'll have 8, 9, 11 in your db, not 10.