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 2005 Forums
 SQL Server Administration (2005)
 Move a Secondary File to a different DB

Author  Topic 

BlakeK
Starting Member

10 Posts

Posted - 2009-07-10 : 16:56:27
I've been all over BOL and Google, but I am just not finding what I need.
I have a database (let's call it DB1) that has a primary file group which contains a DB1.mdf file. And the database has a secondary file group which contains a DB1.ndf file.
I have another database, DB2, which only has a primary file group which contains a DB2.mdf file.
What I want to do is detach the DB1.ndf file from DB1 and then attach it to DB2, so that the tables from this secondary file are now in DB2.
I have been looking at ALTER DATABASE, as well as sp_detach_db and sp_attach_db, but I haven't found anything that looks like it will do what I described above.
Any help would be appreciated. Thanks.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-07-10 : 17:23:17
You can't do it that way. Need to copy the tables with SSIS or T-SQL to DB2.

Create the secondary file in the target db, then move the tables to it. Then you can drop the source tables and the secondary file.

Make a good backup 1st
Go to Top of Page
   

- Advertisement -