Restore Partioned database into multiple filegroups
Posted
by Renju
on Stack Overflow
See other posts from Stack Overflow
or by Renju
Published on 2009-10-30T07:46:17Z
Indexed on
2010/04/30
22:07 UTC
Read the original article
Hit count: 339
sql
|sql-server
does anyone have any query to restore partioned db that having multiple file groups,In the restore option in the SSME i need to edit manually all the path of the filegroups restore as option it little bit tedious as it having more than 150 filegroups
eg:USE master
GO
-- First determine the number and names of the files in the backup.
RESTORE FILELISTONLY
FROM MyNwind_1
-- Restore the files for MyNwind.
RESTORE DATABASE MyNwind
FROM MyNwind_1
WITH NORECOVERY,
MOVE 'MyNwind_data_1' TO 'D:\MyData\MyNwind_data_1.mdf',
MOVE 'MyNwind_data_2' TO 'D:\MyData\MyNwind_data_2.ndf'
GO
-- Apply the first transaction log backup.
RESTORE LOG MyNwind
FROM MyNwind_log1
WITH NORECOVERY
GO
-- Apply the last transaction log backup.
RESTORE LOG MyNwind
FROM MyNwind_log2
WITH RECOVERY
GO
Here i need to specify multiple MOVE command for all my filegroups,this is a tedious task when having more than 100s of filegroups
MOVE 'MyNwind_data_1' TO 'D:\MyData\MyNwind_data_1.mdf',
MOVE 'MyNwind_data_2' TO 'D:\MyData\MyNwind_data_2.ndf'
I need to move the files into the path i provided as a parameter.Please help.
Regards Renju http://blog.renjucool.com
© Stack Overflow or respective owner