我有一个SQL Server实例与两个数据库:
myDB_LIVE
myDB_TEST
都指向单独的mdf和ldf文件,并每晚备份。 我想要一个LIVE的副本,并把它放在testing中。 我甚至想把它当成一个正常的工作,最好的办法是什么?
我可以从一个实时备份恢复,但担心我会覆盖现有的实时数据库,因为它们在同一个服务器实例?
我将把以下内容设置为存储过程,然后创build一个作业,以便每晚运行它:
----Make Database to single user Mode ALTER DATABASE myDB_TEST SET SINGLE_USER WITH ROLLBACK IMMEDIATE ----Restore Database RESTORE DATABASE myDB_TEST FROM DISK = 'D:BackUpYourBaackUpFile.bak' WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf', MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf' /*If there is no error in statement before database will be in multiuser mode. If error occurs please execute following command it will convert database in multi user.*/ ALTER DATABASE myDB_TEST SET MULTI_USER GO