USE [master]
GO
RESTORE DATABASE [GroupFile]
FROM DISK = N'c:\GroupFile.bak'
WITH FILE = 1,
MOVE N'GroupFile_data1' TO N'c:\test\GroupFile_data1.mdf',
MOVE N'GroupFile_data2' TO N'c:\test\GroupFile_data2.mdf',
MOVE N'GroupFile_g11' TO N'c:\test\GroupFile_data11.1df',
MOVE N'GroupFile_g12' TO N'c:\test\GroupFile_data12.1df',
MOVE N'GroupFile_g21' TO N'c:\test\GroupFile_data21.1df',
MOVE N'GroupFile_g22' TO N'c:\test\GroupFile_data22.1df',
MOVE N'GroupFile_log' TO N'c:\test\GroupFile_log.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO数据还原语句如上,我想 把基本中的 c:\test\ 定义成一个 变量 比如Declare @file_path=' c:\test\ '然后引用变量,应该如何写?请各位大侠指点一下,谢谢!
GO
RESTORE DATABASE [GroupFile]
FROM DISK = N'c:\GroupFile.bak'
WITH FILE = 1,
MOVE N'GroupFile_data1' TO N'c:\test\GroupFile_data1.mdf',
MOVE N'GroupFile_data2' TO N'c:\test\GroupFile_data2.mdf',
MOVE N'GroupFile_g11' TO N'c:\test\GroupFile_data11.1df',
MOVE N'GroupFile_g12' TO N'c:\test\GroupFile_data12.1df',
MOVE N'GroupFile_g21' TO N'c:\test\GroupFile_data21.1df',
MOVE N'GroupFile_g22' TO N'c:\test\GroupFile_data22.1df',
MOVE N'GroupFile_log' TO N'c:\test\GroupFile_log.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO数据还原语句如上,我想 把基本中的 c:\test\ 定义成一个 变量 比如Declare @file_path=' c:\test\ '然后引用变量,应该如何写?请各位大侠指点一下,谢谢!
FROM DISK = N''c:\GroupFile.bak''
WITH FILE = 1,
MOVE N''GroupFile_data1'' TO N'''+@path+'\GroupFile_data1.mdf'',
MOVE N''GroupFile_data2'' TO N'''+@path+'\GroupFile_data2.mdf',
MOVE N''GroupFile_g11'' TO N'''+@path+'\GroupFile_data11.1df',
MOVE N''GroupFile_g12'' TO N'''+@path+'\GroupFile_data12.1df',
MOVE N''GroupFile_g21'' TO N'''+@path+'\GroupFile_data21.1df',
MOVE N''GroupFile_g22'' TO N'''+@path+'\GroupFile_data22.1df',
MOVE N''GroupFile_log'' TO N'''+@path+'\GroupFile_log.ldf',
NOUNLOAD, REPLACE, STATS = 10 ')
FROM DISK = N''c:\GroupFile.bak''
WITH FILE = 1,
MOVE N''GroupFile_data1'' TO N'''+@path+'\GroupFile_data1.mdf'',
MOVE N''GroupFile_data2'' TO N'''+@path+'\GroupFile_data2.mdf'',
MOVE N''GroupFile_g11'' TO N'''+@path+'\GroupFile_data11.1df'',
MOVE N''GroupFile_g12'' TO N'''+@path+'\GroupFile_data12.1df'',
MOVE N''GroupFile_g21'' TO N'''+@path+'\GroupFile_data21.1df'',
MOVE N''GroupFile_g22'' TO N'''+@path+'\GroupFile_data22.1df'',
MOVE N''GroupFile_log'' TO N'''+@path+'\GroupFile_log.ldf'',
NOUNLOAD, REPLACE, STATS = 10 ')
FROM DISK = N''c:\GroupFile.bak''
WITH FILE = 1,
MOVE N''GroupFile_data1'' TO N'''+@path+'\GroupFile_data1.mdf'',
MOVE N''GroupFile_data2'' TO N'''+@path+'\GroupFile_data2.mdf'',
MOVE N''GroupFile_g11'' TO N'''+@path+'\GroupFile_data11.1df'',
MOVE N''GroupFile_g12'' TO N'''+@path+'\GroupFile_data12.1df'',
MOVE N''GroupFile_g21'' TO N'''+@path+'\GroupFile_data21.1df'',
MOVE N''GroupFile_g22'' TO N'''+@path+'\GroupFile_data22.1df'',
MOVE N''GroupFile_log'' TO N'''+@path+'\GroupFile_log.ldf'',
NOUNLOAD, REPLACE, STATS = 10 ')