FIX: Distribution Agent Fails when Applying Snapshot if the Table has a Self-referencing Foreign Key (303218)
The information in this article applies to:
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q303218
BUG #: 352248 (SHILOH_BUGS)
SYMPTOMS
If a transactional publication has a table with a self-referencing foreign key, and the table article is configured to include declared referential integrity in a snapshot, the Distribution Agent fails while trying to reapply the snapshot after the first synchronization. The Distribution Agent fails with this error message:
Unable to drop table [Table Name], because it is accessed by a Foreign Key constraint.
CAUSE
When applying the snapshot, the schema files are applied in such a way that the child tables are dropped, and then re-created before the parent tables are re-created. So, even if there are foreign key references, tables can be dropped and re-created successfully. However, if there is a self-referencing foreign key, you must remove the foreign key before you can drop the table. When the Distribution Agent tries to apply the schema of a table that has a self-referencing foreign key the second time, the agent fails with the error message shown in the "Symptoms" section.
This problem occurs if the pre_creation_command option for the snapshot is Drop the existing table and recreate it, and the table article is configured to include declared referential integrity in the snapshot.
RESOLUTIONTo resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the
Microsoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack
WORKAROUND- Drop the self-referencing key manually before you apply the snapshot the second time.
- Use the pre-snapshot script to drop all foreign key references.
STATUSMicrosoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.
Modification Type: | Major | Last Reviewed: | 10/3/2003 |
---|
Keywords: | kbBug kbfix kbSQLServ2000sp1fix KB303218 |
---|
|