Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Issue with SWITCHing partition

Author  Topic 

Bex
Aged Yak Warrior

580 Posts

Posted - 2010-06-29 : 06:22:42
Hi there

I'm new to using SQL Server partitioning. I have 2 schemas within a database, dbo and staging. Each schema contains a set of tables, with PK's, FK's, Unique constraints, Indexes, etc.

Both structures are identical within each schema. Each has a partition constraint and function that partitions the data/indexes based on a date (daily partitions).

When I try to switch the second to last partition in dbo with that in staging, I get the following error:

Msg 4968, Level 16, State 1, Procedure DeleteOldPartition, Line 56
ALTER TABLE SWITCH statement failed. Target table 'CRDMPointOfSale.staging.CRDM_AccountPayment' has foreign key for constraint 'FK_AccountPayment_Header' but source table 'CRDMPointOfSale.dbo.CRDM_AccountPayment' does not have corresponding key.


However, staging does have a FK constraint, but to the Header table within the staging schema. Do the tables have to reference the Header table within dbo??? If so, then how do I switch out the Header table?

I'm confused ....

Hearty head pats
   

- Advertisement -