Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a table with a foreign key constraint and the command below gives me an error because it's trying to set a value that already in the provider table. How do I update this command to ignore those rows that already exist in the provider table?

2 Answers
2

It sounds like you're trying to perform a set based update (which is great) whilst at the same time apply row level based rules. With a set based update, your entire update must either succeed or fail, there's no middle ground.

With this in mind, one solution would be for you to include some logic to validate that the key values do not already exist, prior to performing the update.

It's difficult to formulate a query without sample schema and data but something like this should work for you: