Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2000-09-06 : 23:50:30
|
Brandon writes "Hi, Is is possible to trap errors in SQL? What's I'm trying to do is INSERT into a table, and for the primary key I am just incrementing a number. The problem comes when if two people enter something at the same time, the key generator my generate the same key, so one of the inserts will fail. (I can't let SQL auto generate the keys because they are different depending on how the entry is made, web or console)
So what I'm wanting it to do is if it fails, to try to generate a new key and try the insert again. If that fails then I want it to stop and come back to the user to check and make sure the data entered is correct. (The database has some error checking in it to not allow for data corruption)
I can either have it retry in SQL or in ASP, it doesn't matter to me. I just need to know that there was a problem without it displaying that ADO Error to the client.
I'm using SQL server 7 sp2(?? might be 1, but I think they put 2 on there) and WinNT Server 4, IIS 4, and SP 6a on the server.
Thanks Brandon"
|
|
|
|
|
|