Search code examples
sql-servervisual-studio-2012ssmsdevextreme

Application can open .mdf with no log file but Management Studio can not attach


I installed the DevExpress demo

C:\Users\Public\Documents\DevExpress Demos 15.2\DevExtreme\DXHotels

The demo came with HotelDB.mdf in the App_Data folder.

Out of curiosity I attempted to open the HotelDB.mdf by attempting to attach it using SQL Server 2012 Express Management Studio

However I got an error about a missing log file when I did this.

When I ran the application from the solution the log file created and I was able to subsequently attach using SQL Server.

Why was the application able to open the file when Management Studio could not?


Solution

  • Try one of the following ......

    CREATE DATABASE HotelDB
    ON (FILENAME = N'C:\App_Data\HotelDB.mdf')  --<-- The path to your .mdf
    FOR ATTACH_REBUILD_LOG
    GO
    

    OR

    CREATE DATABASE HotelDB
    ON  (FILENAME = N'C:\App_Data\HotelDB.mdf')  --<-- The path to your .mdf
    FOR ATTACH
    GO