将数据库从一个Azure容器还原到另一个

时间:2015-03-30 09:45:53

标签: sql azure

如何将数据库从一个azure容器还原到另一个容器。我拥有他们两个的所有凭据并为一个容器恢复数据库工作,但在两个之间转移 - 不是。 我正在使用该代码:

RESTORE DATABASE TableName
 FROM URL = 'azure container1/tablename.bak'
 WITH CREDENTIAL = 'ProductionBackupCredential', REPLACE, 
 Move 'TableName' TO 'azure container2/sqldata/tablename.mdf',   
 MOVE 'TableName_log' TO 'azure container2/sqldata/tablename.ldf',Credential = 'StagingBackupCredential';

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

适合我:

  use master
     ALTER DATABASE tablename SET SINGLE_USER WITH ROLLBACK IMMEDIATE
     RESTORE DATABASE tablename 
     FROM URL = 'https://azurestorage/tablename.bak'
     WITH 
     CREDENTIAL = 'ProductionBackupCredential',
     REPLACE, 
     Move 'tablename ' TO 'https://azurecontainer2/tablename.mdf',   
     MOVE 'tablename _log' TO 'https://azurecontainer2/tablename.ldf',

      NOUNLOAD, Recovery, STATS = 10
     ALTER DATABASE tablename SET MULTI_USER
     go