Unanswered: Trapping for a Key Violation Error Code
I have a query that appends records to a sql table. The sql table "tblQueues" has one field that is the primary key (Serial Number Field) which is a sequential number. so I have a procedure that gathers the records that I need to import into the tblQueues table and puts them in a table called tblAlerts then another query queries the tblQueues table for the last Serial Number and assigns the next x number of serial numbers to the tblAlerts records (i.e. 5 records in the tblAlerts table the next 5 Serial numbers will be assigned to the records in the tblAlerts Table).
I want to plan for all possiblities so I want to assume in the 2 or 3 microseconds it takes my proc to run one or more other users are adding records into the tblQueues table thus utilizing one or more of the serial numbers that I have already selected. I want my proc to trap for the Key Violation Error Code and then I want the part of my proc that selects the serial numbers from the tblQueues table to run again and then attempt to append (insert - sql speak) the new records. Unfortuntely, I can not change the tblQueues table and I only have Insert Rights to this table.