Is there a way to avoid row deletion on an specific table using constrains?
I’d like to (for example) deny row deletion if the id is 0,1 or 2
This is in order to avoid users deleting master accounts for an application, and I’d like to avoid it even if someone tries it (by mistake) using sql directly.
Thanks!
EDIT:
The whole idea of this question is not to touch the application. It’s not a matter of security, I just need to know if It’s possible to do what I asked with constrains or any other thing that SQL Server has (It does not need to be an standard db solution).
EDIT 2:
Code samples are very, very appreciated 😀
As far as enforcing this in a constraint, my solution would be to create a dependent table, so referenced rows cannot be deleted.
Now no one can delete rows in
Accountswith id values 0, 1, or 2, unless they first delete the corresponding rows inNoKillI. You can restrict deletions against the dependent table using SQL privileges.