【问题标题】:SSMS drop failed for database "Unable to open physical file"数据库“无法打开物理文件”的 SSMS 删除失败
【发布时间】:2017-05-25 19:18:05
【问题描述】:

试图在其他地方找到这个但没有运气。

我正在尝试删除磁盘上不再存在但仍显示在 SSMS 2014 的对象资源管理器中的数据库

那么我怎样才能从对象资源管理器中“清除”它们呢?

我需要手动从 sys.master_files 中删除它们吗?

例外是:

    Drop failed for Database 'aspnet-Blawblaw-20141027015559'.  (Microsoft.SqlServer.Smo)

    ------------------------------
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=12.0.2000.8+((SQL14_RTM).140220-1752)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+Database&LinkId=20476

    ------------------------------
    Program Location:

       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImpl()
       at Microsoft.SqlServer.Management.Smo.Database.Drop()
       at Microsoft.SqlServer.Management.SqlManagerUI.DropObjects.DoDropObject(Int32 objectRowIndex)
       at Microsoft.SqlServer.Management.SqlManagerUI.DropObjects.DropAllObjects(Boolean stopOnError)

    ===================================

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

    ------------------------------
    Program Location:

       at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
       at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
       at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ExecuteNonQuery(StringCollection queries, Boolean includeDbContext)
       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImplWorker(Urn& urn)
       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImpl()

    ===================================

    Unable to open the physical file "C:\Projects\BlawBlaw\BlawBlaw\App_Data\aspnet-BlawBlaw-20141027015559.mdf". Operating system error 3: "3(The system cannot find the path specified.)".
    File activation failure. The physical file name "C:\Projects\BlawBlaw\BlawBlaw\App_Data\aspnet-BlawBlaw-20141027015559_log.ldf" may be incorrect. (.Net SqlClient Data Provider)

    ------------------------------
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.3000&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476

    ------------------------------
    Server Name: (LocalDb)\v11.0
    Error Number: 5120
    Severity: 16
    State: 101
    Line Number: 2


    ------------------------------
    Program Location:

       at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
       at Microsoft.Sq

【问题讨论】:

    标签: ssms sql-server-2014 drop-database


    【解决方案1】:
    【解决方案2】:

    这对我有帮助。

    1. 打开新查询
    2. 复制数据库名称(F2)
    3. 运行此命令:DROP DATABASE [C:TEST.MDF]
      -- 当“test”是数据库的名字时
    4. 执行
    5. 刷新后,数据库下不显示DB字符串

    【讨论】:

    • Msg 3701, Level 11, State 1, Server COMPUTER\LOCALDB#SHC670BC, Line 1 Cannot drop the database 'C:Test.mdf', because it does not exist or you do not have permission.
    【解决方案3】:

    您需要运行的步骤如下:

    • 打开命令提示符
    • 如果 localDb 实例尚未运行,请启动它:“C:\Program Files\Microsoft SQL Server\120\Tools\Binn\sqllocaldb.exe” start “MSSQLLocalDb″
    • 通过运行以下命令删除 localDb 数据库:“C:\Program Files\Microsoft SQL Server\120\Tools\Binn\sqlcmd” -S (localdb)\MSSQLLocalDb -E -d master -Q “DROP DATABASE [myDatabase]”
    • 您现在可以停止 localDb 服务:“C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqllocaldb.exe” stop “MSSQLLocalDb″

    来源:http://kazimnami.azurewebsites.net/techblog/2013/02/27/delete-localdb-database-after-physical-files-have-been-deleted/

    【讨论】:

    • Msg 5120, Level 16, State 101, Server COMPUTER\LOCALDB#SHC670BC, Line 1 Unable to open the physical file "C:\Users\User\Test.mdf". Operating system error 2: "2(The system cannot find the file specified.)". File activation failure. The physical file name "C:\Users\User\Test_log.ldf" may be incorrect.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多