two users using one application and same database, when both of them are trying to insert new record at the same time on the same table of same database, they got same id. so how to restrict them from inserting such record and how to identify that both are going to save data with same id.?


1 Answer 1


You need to create a primary key or a unique index on the column. The application should have code to pass the error from the SQL server that a primary key violation would occur if the record is inserted. You can also create a trigger to send an alert to yourself as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.