Click here to Skip to main content
15,999,626 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have two different databases PrimaryDB and BackupDB. In PrimaryDB I have a table which was partition on the basis of Date. In BackupDB i have a table which has the same structure as in PrimaryDB. I need to transfer the partition from PrimaryDB to SecondaryDB. Is it possible to do with Switch Parition? When I tried to do that. I got the error message saying: ALTER TABLE SWITCH statement failed. The source table 'sales' is in database 'PrimaryDB' while the target table 'BackupDB.DBO.sales_backup' is in database 'BackupDB'.

In some websites, they have mentioned if we use same file group we can be able to do it. I tried that also it is not working for me. If anyone has any links or tried out examples please post it.

Thanks in advance.
Posted

1 solution

Hey,

As per your question you need to copy the data of PrimaryDB to SecondaryDB.

Insert into Table_of_SecondaryDB
select * from ServerName.DatabaseName.dbo.Table_NameOf_PrimaryDB
where ColumnName_Of_PrimaryDB not in (Select ColumnName_Of_SecondaryDB from Table_of_SecondaryDB)
 
Share this answer
 
Comments
LEBON Iniyavan 22-May-14 0:39am    
Hi,
I have to transfer a single partition,and that should be a cut and paste.. thats y i have used Partition Switching. But is it nt possible to do so..? But the Alter Switch Statements fails even I created both the table in the same filegroup..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900