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
 SQL Server Administration (2008)
 Restore to a different File Group

Author  Topic 

JazzieG1316
Starting Member

3 Posts

Posted - 2012-02-17 : 02:14:08
Is there a way to perform a restore to a different file group?

I have a database "DataBase1" whose default primary group is PRIMARY. I created another database "DataBase2" I then created a file group in "Database2" "FileGroup1" I need to restore Database1 to Database2 and the contents of PRIMARY filegroup should then be transfered to "FileGroup1"

Is there a way to do this straight forward through restoration?

There is a way to transfer all of the objects but it is not straight forward.
1. Restore Database1 Backup on Database2.
2. create "FileGroup1" on Database2
3. Create a temporary clustered index on all tables specifying the new filegroup to transfer the contents to the new filegroup.
CREATE CLUSTERED INDEX IDX_TEMP ON [dbo].[TABLE1](Column1)
ON FileGroup1
GO
4. Drop the temporary clustered index
DROP INDEX IDX_TEMP ON [dbo].[TABLE1]
GO

Is there a way to restore to a different file group. Opinions and suggestions are most welcome.

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-02-17 : 04:25:35
No, there's no way through restore to do it. Do it the way you have listed but why are you dropping the clustered index afterwards? All SQL tables (with very few exceptions) should have a clustered index

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -