none
how to drop a database logical name when physical file is missing

    Question

  • I want to remove the database reference from the master database after the physical database files got deleted from windows explorer

    the smo statements I use are the following

    srv.KillAllProcesses(db.Name)
    
    srv.KillDatabase(db.Name)

     

    the error message that I get states:

    - kill database failed

    - unable to find the physical file at location XXXX

    Is there a stored procedure that I can use that solves this problem

    • Edited by carrera7 Wednesday, December 08, 2010 12:40 PM update font sixze
    Wednesday, December 08, 2010 12:38 PM

Answers

  • You can drop the database using T-SQL:

    DROP DATABASE MyBadDatabase;
    

    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    • Marked as answer by carrera7 Wednesday, December 08, 2010 1:25 PM
    Wednesday, December 08, 2010 12:47 PM

All replies

  • You can drop the database using T-SQL:

    DROP DATABASE MyBadDatabase;
    

    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    • Marked as answer by carrera7 Wednesday, December 08, 2010 1:25 PM
    Wednesday, December 08, 2010 12:47 PM
  • Dan

     thanks DROP worked.

    I thought that KILL was the more resilient or mean version of delete database

    Wednesday, December 08, 2010 1:25 PM