• martin.kerr 34088 (1/11/2012)


    Hi,

    I found this from googleing my problem and it worked!

    Create database with same name as MDF file you have.

    Stop SQL Server and swap MDF files. Make sure you also keep new database you just created.

    Start SQL Server. Database will be now in suspect state because log file is not correct.

    Run the following script:

    USE [master]

    GO

    ALTER DATABASE [MyDatabase] SET EMERGENCY

    GO

    ALTER DATABASE [MyDatabase] SET SINGLE_USER

    GO

    DBCC CHECKDB ([MyDatabase], REPAIR_ALLOW_DATA_LOSS)

    GO

    ALTER DATABASE [MyDatabase] SET MULTI_USER

    GO

    ALTER DATABASE [MyDatabase] SET ONLINE

    GO

    Thanks anyway

    To re attach a database with a missing log file just use either

    sp_attach_single_file_db

    CREATE DATABASE .... FOR ATTACH_REBUILD_LOG

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉