sql - Cannot delete tables with primary/foreign key relationships -
There are 30 tables in my database and all primary and foreign key relationships are related to each other. The problem is that when I try to delete any record through any stored procedure, so it does not remove the primary / foreign key due to relationship. What should I do to delete tables? Too many tables are connected.
ALTER process [dbo]. [DeleteRegions_SP] @RegionID SMALLINT Beginning in the field regionId = @RegionID where the end start catching ERROR_MESSAGE (try to delete error) Try the try and delete from the start end capture and
SQL has three ways of assessing this general condition:
at DELETE CASCADE
which will remove the records that you want to remove depending on the removal. DELETE SET NULL
on the
which taps the FK field and
at DELETE The restriction will be set on
> The one who got hit against you is the default.
TSQL can also
at DELETE SET DEFAULT
which can be useful.
There is no solution for you (especially not a casement)!
You will have to decide about each FK what will be the correct segments!
Database design is an art ..
This answer is not to delete the record; If you want to delete the actually table, then you should first take the FK relationship which depends on them.
Comments
Post a Comment