How to recover database from MDF in SQL Server 2005?

后端 未结 9 440
野性不改
野性不改 2021-01-31 11:20

I have an MDF file and no LDF files for a database created in MS SQL Server 2005. When I try to attach the MDF file to a different SQL Server, I get the following error messa

9条回答
  •  时光说笑
    2021-01-31 12:20

    I hope it is easy to do so,

    1. Open SQL Server
    2. Click New Query
    3. Execute the following query

      sp_attach_single_file_db @dbname='dbname',@physname='C:\Database\dbname.MDF'

    Where dbname is you want to show in Object Explorer, where @physname is the local filepath location of your mdf file.

    Hope it will help someone, i done by above, got both structure and also data.

    Tested in Sql Server 2000 and 2008. In Sql Server 2000 it is not working, but works perfectly in 2008.

提交回复
热议问题