How to create unique user key
- by Grayson Mitchell
Scenario: I have a fairly generic table (Data), that has an identity column. The data in this table is grouped (lets say by city).
The users need an identifier in order for printing on paper forms, etc.
The users can only access their cites data, so if they use the identity column for this purpose they will see odd numbers (e.g. a 'New York' user might see 1,37,2028... as the listed keys.
Idealy they would see 1,2,3... (or something similar)
The problem of course is concurrency, this being a web application you can't just have something like:
UserId = Select Count(*)+1 from Data Where City='New York'
Has anyone come up with any cunning ways around this problem?