我也试过了:
CREATE DATABASE [SampleDB] ON PRIMARY
( NAME = N'SampleDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDB.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB ),
FILEGROUP [FG2]
( NAME = N'F2', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\F2.ndf' , SIZE = 3072KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'SampleDB_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\SampleDB_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)
GO
BACKUP DATABASE SampleDB
TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup1.bak' WITH INIT
BACKUP DATABASE SampleDB FILEGROUP = N'FG2'
TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup2.bak'
RESTORE DATABASE RestoreDB
FILEGROUP = N'PRIMARY'
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup1.bak'
WITH
MOVE N'SampleDB' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\RestoreDB.mdf',
MOVE N'SampleDB_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\RestoreDB_log.ldf'
RESTORE DATABASE RestoreDB
FILEGROUP = N'FG2'
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\BACKUP\backup2.bak'
WITH
MOVE N'F2' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\RestoreDB2.ndf'
但我得到一个错误:
提供的备份与数据库不在同一恢复路径上,并且不适合用于在线文件还原。
我不知道,因为从来不需要这样做,但不可能移动它,Paul Randal 在这里回答这个问题:http ://www.sqlservercentral.com/Forums/Topic412470-357-1.aspx