USE master
GO
-- First determine the number and names of the files in the backup.
-- MyNwind_2 is the name of the backup device.
RESTORE FILELISTONLY
FROM DISK='F:/20080313erp_0.bak'
-- Restore the files for MyNwind2_Test.
RESTORE DATABASE ERP_2
FROM DISK='F:/20080313erp_0.bak'
WITH RECOVERY,
MOVE 'ERP_0_Data' TO 'D:/system/date/DATAERP_2_Data.mdf',
MOVE 'ERP_0_Log' TO 'D:/system/daste/DATAERP_2_Log.ldf'
GO
exec master..xp_cmdshell 'copy "D:/system/data/ERP_Data.MDF" "D:/system/data/ERP_2_Data.mdf"'
exec master..xp_cmdshell 'copy "D:/system/data/ERP_Data.MDF" "D:/system/data/ERP_2_Data.mdf"'
exec master..xp_cmdshell 'del "D:/system/data/ERP_2_Data.mdf"'
EXEC sp_detach_db erp2
// (")双引号 问题的解决
Filename:=StringReplace(ExtractFilePath(Paramstr(0)),':','::',[rfReplaceAll]);或存储过程