sql server - Checking rule violations before deleting a record -
I would like to implement the "soft-delete" scheme for many organizations in my SQL Server 2005 database. That means, I mean that I would like to delete a line from the table if there is no referenced integrity rule violation, otherwise I will set the flag on the record, indicating that it has been removed. In the table that I wish to apply this "soft-delete" pattern, should be applied in the form of "insert / update specificity" as "no action".
How can I check to see if the foreign key barriers will be violated to run what I am excluding?
I do not want to capture exceptions - I want to see clearly whether the rules will be violated or not. I do not even want to manually check it through the SELECT statement (Maintenance Nightmare) manually. I would prefer a solution in T-SQL; But I am using unit framework, so if one exists for this task then it would be possible to use an API.
Note that there is a similar question, but the submitted responses are not conforming to my needs. Like the solution of Ed Harper, I would also recommend that you use an Instalated Dealit trigger, but we are different in our solution, I really want you to check the desired integrity / rules, in fact I propose to configure my database.
In this way, when a deleted operation can not be successfully completed within the trigger code, due to a violation of the obligation, you
optionally, no violation Should be done, the deleted operation will only be completed successfully.
This implementation ensures that DBMS maintains complete responsibility for managing the database integrity, of course the desired scenario should be.
Understanding Mac E?
Comments
Post a Comment