none
ERROR 5120

    Question

  • I tried attach/detach approach to migrate sql server 2000 databases to sql 2005. I installed a fresh copy of sql  server 2005 on windows 2003 server. I could move most of my databases except one. While attaching the database to the sql 2005 I got the following error:

    Unable to oen "c:\program files\microsoftSQL server \MSSQL.1\MSSQL\DATA\mydb_log.ldf". operating system error 32:" 32(the process cannot access the file because it is being used by another process)". microsoft SQL server, error:5120)

     

     

     

    Wednesday, September 06, 2006 2:37 PM

Answers

All replies

  • You must be attaching the wrong file (one being used by another database).
    Thursday, September 07, 2006 10:35 PM
  • I have a similar problem with the same error:

    1) Detached MyDb.mdf (and .ldf) (Auto close = True)

    2) copied MyDb.mdf and MyDb.ldf to a different folder

    3) Re-attached MyDb from original location

    4) Renamed copy to MyDbX.mdf and MyDbX.ldf

    5) Attach copy (MyDbX.mdf), and in attach dialog change "Attach  As" column to MyDbX

    = Error 5120

    Problem was the rename at step 4. Without this step the attach works OK, with step 5 renaming the database.

    Without going back to check, I think step 4 was ok in SQL 2000 EM.

    Saturday, October 07, 2006 12:49 PM
  • Hi,

    This could also be related to the access rights. By giving 'Full control' to Sql Server admins on the folders where the sql data and log file is placed could resolve the issue.

     

    • Proposed as answer by Arisa Oktavia Tuesday, August 02, 2011 4:51 AM
    • Unproposed as answer by Arisa Oktavia Tuesday, August 02, 2011 4:51 AM
    Monday, January 21, 2008 3:58 PM
  • I also had the same problem in Vista,

    Please try this

    - Go to Control Panel and Switch to Classic View
    - Click on User Accounts
    - Click on Turn User Account Control on or off
    - Uncheck use User Account Control (UAC) to help protect your
    computer.
    - OK
    - Restart System

    Try again to attach the DB. It should work now.

    Thanks
    Tuesday, July 29, 2008 7:02 AM
  •  

    My problem was solved, bu running the SQL server Management Studio as administrator, and then attach the database.
    • Proposed as answer by tizard Sunday, September 12, 2010 6:06 PM
    Tuesday, August 05, 2008 12:51 PM
  • intente primero entrar con autentificacion de windows, luego intente hacer el attach, si no funciona de esta manera intentelo hacerlo como usuario "sa"
    Friday, September 26, 2008 7:47 PM
  • This worked for me :)
    Tuesday, October 13, 2009 8:45 AM
  • Vista and UAC :s
    Running as Admin fixed the problem for me, thank you!
    Monday, November 16, 2009 10:24 AM
  • I had a similar problem on window 7, but running as sql server studio express as an administrator solved the problem, you guys are great, thank you
    Wednesday, January 20, 2010 9:45 PM
  • copy the data base to d:\ and try to add the databasefrom d: , i think your problem will solved ,,,

     

    Thanks Dude

    Satish

    Wednesday, March 24, 2010 6:21 AM
  • It works for me too thanks guys.
    Monday, June 14, 2010 11:42 AM
  • JOHAR THANKS MY PROBLEM IS ALSO SOLVED BY RUNNING SQL SERVER AS A ADMINISTRATOR
    Sunday, September 05, 2010 7:06 PM
  • Hey, I had this problem too, but it was when I updated from sql 2005 to sql 2008, but my problem was only the firewall that didn't allow to sql see the DataBases.
    Tuesday, September 07, 2010 4:11 AM
  •  

    My problem was solved, bu running the SQL server Management Studio as administrator, and then attach the database.

    Thank you, thank you, a thousand thank you's, this was it. No Thank you Microsoft...... Suprised this isn't the 1st thing suggested to be checked!
    Sunday, September 12, 2010 6:08 PM
  • My problem was not solved by this. The error message

     

    Attach database failed for Server 'server-pc'.  (Microsoft.SqlServer.Express.Smo)

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

    ADDITIONAL INFORMATION:

    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

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

    Unable to open the physical file "E:\librarydata.mdf". Operating system error 5: "5(error not found)". (Microsoft SQL Server, Error: 5120)

    And no other post here helped me. Any solution?

    Thursday, February 17, 2011 5:41 AM
  • thank you
    Friday, March 11, 2011 9:21 AM
  • thanks, this worked for me in Windows 7 HP :)
    Saturday, October 01, 2011 4:40 PM
  • YOU'RE ABSOLUTELY RIGHT THAT REALLY WORKS, NOW I CAN do My HOMEWORK OF DATA BASE I,  thanks alot!!
    Wednesday, February 29, 2012 2:15 AM
  • Worked for me.  Thanks.

    I really wish Microsoft would fix security issues.  We have to run as administrator even when we're already in the administrator group??

    And just to run something from a webpage, you have to click yes or run 3 times..... but there's still tons of viruses and malware successfully getting installed

    Friday, June 08, 2012 5:56 PM
  • Hello all,

    Please Open Sql Server ManagementStudio as Run as Administrator

    This will solve the problem.

    Friday, July 06, 2012 8:36 AM
  • hi nabila try this :

    1.right click on the mdf and or ldf file  - properti - tab security - choose your user - edit - check for full control - ok - then try to attach database again.


    Friday, December 21, 2012 4:57 AM
  • It did work this way :) Thanks a million!
    Thursday, July 04, 2013 3:37 PM
  • Yup!! bro ..It helps me..learn something new...Thanks.

    Wednesday, December 04, 2013 9:36 AM
  • Run SQL Server Management Studio as ADMINISTRATOR and the problem will be solved!...
    Tuesday, December 10, 2013 3:55 AM