要创建一个新数据库并从备份中填充它,我通常会这样做:
CREATE DATABASE MyDatabase -- I create an empty database
-- I retrieve the filepath of mdf and ldf files
DECLARE @FileData varchar(1000)
DECLARE @FileLog varchar(1000)
set @FileData = (select filename from MyDatabase.dbo.sysfiles where fileid = 1)
set @FileLog = (select filename from MyDatabase.dbo.sysfiles where fileid = 2)
-- I Restore the database from backup by substituting the mdf and ldf files
RESTORE DATABASE MyDatabase
FROM DISK = 'c:\Test\Test.bak'
WITH REPLACE,
MOVE 'MyApp_Data' TO @FileData, -- I forced the name to be MyApp_Data for simplicity
MOVE 'MyApp_Log' TO @FileLog -- I forced the name to be MyApp_Log for simplicity
如何对文件流数据也做同样的事情?我可以强制为文件流数据创建文件夹还是应该手动创建它?
你也可以评论我的方法吗?