How we restore DB through single .MDF file

  • How we restore DB through single .MDF file.

    I have only .mdf File so without .log file we can Restore Database. Is it Possible.

    I already tried Procedures that are

    sp_attach_db

    sp_attach_single_file_db

    But its not work.

    There is any other way to Restore Database.

    Please help me.

    Thanks.

    Sachin Bhaygude


    Sachin Bhaygude

  • Using sp_attach_db on its own to create the database object from a sinlge mdf file should work. If no ldf is present,sqlserver should realise,and then create a new one for the db object. Any chance that the mdf has been corrupted?

  • Attaching a MDF will only work if you previously detached the database first.

    ( then the database will be in a consistent state ) only then you can attach the MDF.

    If the database was not detached first, there is only an inconsisten MDF and SQL will refuse to attach it.....

    I never figured out a way to get toi the data in such a database........

  • It is generally possible barring differences. When you have a single MDF and no LDF then you use

    sp_attach_single_file_db

    but you stated you tried that already. Whats was the error you got when you tried and exactly what did you do?

    Also if you are using SQL 7 you cann attach an MDF from SQL 2000. Also an MDF from Access cannot be attached. The error should give some idea what is wrong thou.

  • The db_papoulias_gr is DB name.

    I am using sql server 2000.

    I tried as,

    exec sp_attach_single_file_db @dbname = 'db_papoulias_gr',

    @physname = 'C:\Program Files\Microsoft SQL Server\MSSQL\data\db_papoulias_gr_data.mdf'

    I had following error :

    " Could not open new database 'db_papoulias_gr'. CREATE DATABASE is aborted.

    Device activation error. The physical file name 'C:\Program Files\Microsoft SQL Server\MSSQL\data\db_papoulias_gr_log.ldf' may be incorrect. "

    Why it gives .log file eror. Basically if .log file does not exist then it creates new log file.

    Can i made any mistake. Please help me.

    Thanks

    Sachin Bhaygude


    Sachin Bhaygude

  • Have you double-checked to make sure this file does not exist?

    'C:\Program Files\Microsoft SQL Server\MSSQL\data\db_papoulias_gr_log.ldf'

    It looks like SQL Server thinks it still exists.

    -SQLBIll

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

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