|
Home > Archive > MS SQL Server > November 2006 > Delete records in a table with 15 dependencies
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Delete records in a table with 15 dependencies
|
|
|
| Hi, I need to delete records in a table with 15 dependencies.
I can't drop the 15 dependencies before delete records.
Any ideas to delete records without dropping dependencies
Thanks,
| |
| Paul Ibison 2006-11-16, 7:12 pm |
| Do you mean you want to delete a PK record which is used as a FK in 15
tables?
You could change the cascade option on the FKs to be a setting other than
the default - from BOL: ON DELETE { NO ACTION | CASCADE | SET NULL | SET
DEFAULT }
Alternatively you could temporarily disable the FK constraint (ALTER TABLE
cnst_mytable NOCHECK CONSTRAINT myfk), although I'd doubt the wisdom of this
approach.
Thinking a little wider, I'd like to know more about the design you have
which will need to allow for orphaned records, if I have understood this
correctly.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
| |
|
| Thanks a lot.
Your concern is correct 100%.
We are doing the test only for the same concern
"Paul Ibison" <Paul.Ibison@Pygmalion.Com> wrote in message
news:%23eBTMeZCHHA.4224@TK2MSFTNGP06.phx.gbl...
> Do you mean you want to delete a PK record which is used as a FK in 15
> tables?
>
> You could change the cascade option on the FKs to be a setting other than
> the default - from BOL: ON DELETE { NO ACTION | CASCADE | SET NULL | SET
> DEFAULT }
> Alternatively you could temporarily disable the FK constraint (ALTER TABLE
> cnst_mytable NOCHECK CONSTRAINT myfk), although I'd doubt the wisdom of
> this approach.
>
> Thinking a little wider, I'd like to know more about the design you have
> which will need to allow for orphaned records, if I have understood this
> correctly.
>
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .
>
|
|
|
|
|