簡體   English   中英

將分區數據庫還原到多個文件組

[英]Restore Partitioned database into multiple filegroups

我需要還原具有多個文件組的分區數據庫。 在SSME的restore選項中,我需要手動編輯文件組的所有路徑,將其還原為選項有點繁瑣,因為它具有150多個文件組

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

在這里,我需要為我的所有文件組指定多個MOVE命令,當有100個文件組時,這是一個繁瑣的任務

   MOVE 'MyNwind_data_1' TO 'D:\MyData\MyNwind_data_1.mdf', 
           MOVE 'MyNwind_data_2' TO 'D:\MyData\MyNwind_data_2.ndf'

我需要將文件移到作為參數提供的路徑中。

您可以使用以下查詢生成MOVE列表:

select 'MOVE ''' + name + ''' TO ''D:\MyData\' + name + '.mdf'','
from sys.filegroups

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM