Attach Database from HardDrive

  • Dear All,

    I Have one database named PK in my database list. Now i had stop the sql services then remove the pk.mdf and pk.ldf files from harddrive.

    Then i had again start the sql services. After then when i start the sql mamagement studio and connect to the server the database is not in the list which i had removed form hard drive.

    Now I have both files PK.MDF and PK.LDF.

    When i tried to attach database using right click on database and attach then i got this error (An error occurred when attaching the database(s). Click the hyperlink in the Message column for details.)

    Can i restore my PK database again using this two files?????????

  • Hi there,

    You can use the Attach Database option where you can specify the .mdf and .ldf files to be attached and a new database will be created.

    Is this what you are interested in?

    Regards,

    Oana.

  • From the description, you did not detach the database prior to removing the files. There are still entries for that database in your master & msdb databases. Trying to reattach without either deleting or detaching (or going to a new machine that's never seen this db before) won't work.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

Viewing 3 posts - 1 through 2 (of 2 total)

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