July 18, 2013 at 7:22 am
How can I dynamically create my FILEGROUP during a restore?
My FILELISTONLY renders
[font="Courier New"]LogicalName PhysicalName Type FileGroupName
=========== ============ ==== =============
MyDBData_Primary G:\SQLData\Archive_Primary.mdf D PRIMARY
MyDBData_1 G:\SQLData\MyDB_1.ndf D DataFileGroup
MyDBData_2 G:\SQLData\MyDB_2.ndf D DataFileGroup
MyDBLog L:\SQLLogs\MyDB.ldf L NULL[/font]
How can I tweak the following RESTORE command to dynamically generate the FileGroupName called 'DataFileGroup' listed above?
RESTORE DATABASE MyDB FROM DISK='H:\SQLBACKUPS\MyDB.bak'
WITH RECOVERY, REPLACE,
MOVE 'MyDBData_Primary' TO 'E:\SQLData\MyDB_Primary.mdf',
MOVE 'MyDBData_1' TO 'E:\SQLData\MyDB_1.ndf',
MOVE 'MyDBData_2' TO 'E:\SQLData\MyDB_2.ndf',
MOVE 'MyDBLog' TO 'F:\SQLLogs\MyDB.ldf'
GO
July 18, 2013 at 7:25 am
You don't need to. The restore will create an exact copy of the database, including filegroups.
John
July 19, 2013 at 4:47 am
John - thanks. Right on w/ your reply. The restore created the FG. Appreciate your feedback.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply