Attach dtabase

  • Hi all,

    how can we attach a database with only .MDF file. I tried using sp_attach_single_file_db command but it's not working. plz help. Thanx in advance

  • Any errors that you are getting?

    He who knows others is learned but the wise one is one who knows himself.


    He who knows others is learned but the wise one is one who knows himself.

  • Is there log file. If it exists, rename log file and just use attach mdf file by using sp_attach_db. It works, automatically it creates new log file. Be remember log file original name. If MDF is not attached, then try with both files.

    madhusudannaidugundapaneni


    Madhu

  • The log file is missed. i tried with sp_attach_db it is not attaching

  • Are there any error messages? In Enterprise Manager,drill down to Management, expand that, expand SQL Server Logs. Double click on the most current log. Also, check the Windows Event Logs.

    Next question: was the database DETACHED????

    Last questions (for now): are you trying to attach it to the SAME server? Or is this a new or reinstalled server?

    -SQLBill

  • I want to attach the database in a different sever. First i stopped sql server and copied the mdf file into a cd and tried to attach in a different server. i haven't dettached the database. Databasename is mlm

    The Error:

    error 1813:Could not opennew database 'mlm'.Create database is aborted.Deviceactivation error.the physicalfile name 'path.....LDF' may be incorrect

  • Have you detached the database.

    BOL States that:

    sp_attach_db should only be executed on databases that were previously detached from the database server using an explicit sp_detach_db operation

    He who knows others is learned but the wise one is one who knows himself.


    He who knows others is learned but the wise one is one who knows himself.

  • The databse is not detached .only copied after stoping the server. now how can i attach the database?

  • Restart the SQl server Service.

    Issue the sp_detach_db command for the database you want to copy on some other place.

    Copy the .mdf and .ldf to the location of your choice and then issue the sp_attach_db command.

    Hope this works out.

    He who knows others is learned but the wise one is one who knows himself.


    He who knows others is learned but the wise one is one who knows himself.

  • i don't have the proper .ldf file. the mdf file is only copied to cd.

  • since the database does not exists in the new server the attach command will fail...try this create the database on the new server, detach the database and reattach the "copied" database

  • I tried that also it's not working.

  • swede,

    The database does not need to exist on the new server for it to be attached. I have done this several times.

    koithodan,

    The problem is that you never detached the original database properly. You need to go back to the original database, detach it, copy the .mdf and .ldf files, then copy them from the cd/tape to the proper file and attach them. You CANNOT attach them from the cd/tape, they must be copied to the proper file first.

    -SQLBill

Viewing 13 posts - 1 through 12 (of 12 total)

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