I have a customer
table and an order
table in an sql server 2000 database.
I don't want an order to be in the order
table with a customerID
that doesn't exist in the customer
table so I have put a foreign key constraint on customerID
.
This all works fine but when writing a stored procedure that could possibly violate the constraint, is there a way to check whether the constraint will be violated and, if it will be, skip/rollback the query?
At the minute all that happens is the stored procedure returns an error that is displayed on my asp page and looks rather ugly + most users wont understand it.
I would like a more elegant way of handling the error if possible.
Thanks