无法创建文件“ E:\ Data \ IMSFullProdCopy.mdf”,因为该文件已经存在。更改文件路径或文件名,然后重试该操作

时间:2019-12-26 17:28:29

标签: sql-server

我出于某种原因创建了一个数据库,在我使用“删除数据库”命令删除之后,我需要删除该数据库-现在,当我尝试使用Management Studio创建数据库时-我收到错误消息:

然后我遇到以下错误:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Create failed for Database 'IMSFullProdCopy'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.6000.34+((KJ_SP3).140819-1214+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

Cannot create file 'E:\Data\IMSFullProdCopy.mdf' because it already exists. Change the file path or the file name, and retry the operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5170)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=13.00.4522&EvtSrc=MSSQLServer&EvtID=5170&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

创建数据库后,我要运行以下脚本:

  use master;
    --kill connections
    ALTER DATABASE IMSFullProdCopy SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--Restore

RESTORE DATABASE IMSFullProdCopy
FROM DISK =
'C:\Users\sa_aaleem\SomeBakcup\IMSFullCopy_20191224.bak'
WITH MOVE 'IMSFullProdCopy' TO 'E:\Data\IMSFullProdCopy.mdf',
MOVE 'IMSFullProdCopy_log' TO 'F:\Log\IMSFullProdCopy.ldf',
STATS = 1, REPLACE
GO

对此有任何帮助-谢谢。

0 个答案:

没有答案