I'll try to word this as best I can.
I'm coding a website using C# MVC4 with a MS SQL database. Whenever a user submits an application via the website I do a look-up on the table, find the highest numbered session code (7 digit, number) add 1 to this number and populate it in the database along with the user details.
We are on the verge of starting a huge add campaign and there will be a massive influx of users. I am worried that if two users submit their applications at the same time that the same session code will be generated for both. What are some practices to stop this? I'm thinking make the field unique in the DB and have a loop surrounding my session code generation and population to try again should it fail.
Is there a better practice than this (other than creating a composite primary key)?