.mdf and .ldf gets deleted

  • .mdf and .ldf gets deleted. Services were stopped and .mdf and .ldf gets deleted. Tried to rebuild the master, no go. also have master database back up, however it is of no use since sql server won't start with services stopped and without .mdf and .ldf. Could any one tell me if any other possible steps which can be performed other than reinstalling SQL server 2005???

  • I have never known a situation where any db file was deleted incorrectly by SQL Server. Most likely is someone deleted them manually either when the service was not running, or by detaching or closing the db and then deleting them. (Unless the db is set to auto close, or detached then the files will be in use by the sql server process and you will not be able to delete them.)

    If this was a user database then restore from the last backup, if it was master then you will either need to rebuild master or restore from a backup, but to do that will need sql server running in single user mode.

    What db was it?

    Mike John

  • randhirdadwal (4/3/2009)


    .mdf and .ldf gets deleted. Services were stopped and .mdf and .ldf gets deleted.

    Any idea who did that? There should be entries in the application event log and they may contain the username of the person who shut the instance down

    Tried to rebuild the master, no go.

    Why not? What's wrong there?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • First step, get a working Master database.

    Take your installation media and run setup again with the following switches:-

    setup.exe /qn INSTANCENAME=”MSSQLSERVER” REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=”mypassword”

    where mypassword is the sa password.

    INSTANCENAME=”MSSQLSERVER” for a default instance of SQL 2005 or ”MSSQL$INSTANCENAME” for a named instance of SQL 2005.

    Second step

    Open a command prompt and navigate to the SQLSERVR.EXE file.

    Run this from the command line with the following swicthes:-

    SQLSERVER.EXE -m -c

    Third Step

    You can now connect to the instance in Management Studio, restore the Master database from your most recent backup using the GUI.

    Fourth Step

    Close the command prompt, and start SQL Server normally.

    Fifth Step

    Restore any other missing databases - including model and msdb if these have also been lost.

    Good luck

  • randhirdadwal (4/3/2009)


    .mdf and .ldf gets deleted. Services were stopped and .mdf and .ldf gets deleted.

    True, if you want to delete the files the server/instance should be shut down. I take it you are refering to master .mdf and .ldf, But have you not got any alerts set up while this is happening and also operators were not notified?

    Tried to rebuild the master, no go.

    more insight into this please?

    also have master database back up, however it is of no use since sql server won't start with services stopped and without .mdf and .ldf.

    Could any one tell me if any other possible steps which can be performed other than reinstalling SQL server 2005???

    Yes, true have you got any instances running or any other servers running?

    you can restore the backups to that server with a different name, detach them, move the files over to the server that is not running, rename them to master files and start the sql server.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply