I would like to implement the “soft-delete” scheme for several objects in my SQL Server 2005 database. By this I mean that I would like to delete a row from the table if there are no violations of the reference integrity rule, otherwise I set the flag in the record to show that it has been deleted. The table that I want to apply for this “soft delete” template should say “No action” as “Insert / Update Specification”.
How to check if the deletion I want to run will violate the foreign key constraints?
I do not want to catch exceptions - I would like to explicitly check if the rules are violated. I also do not want to manually check with SELECT statements (a nightmare for maintenance). I would prefer a solution in T-SQL; but I am using the Entity Framework, so it would be possible to use the API if it exists for this task.
Please note that there is a similar question here, but the answers provided do not meet my requirements.
source
share