locked
access denied RRS feed

  • Question

  • Hi folks,
    
    I receive this error when I attempt to attach a database. I am not sure what setting I need to change. I own the computer, so it isn't a network issue. I tried running Management Studio as Administrator as well. Can someone point me in the right direction?
    
    TITLE: Microsoft SQL Server Management Studio
    ------------------------------
    
    Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
    
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
    
    ------------------------------
    ADDITIONAL INFORMATION:
    
    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
    
    ------------------------------
    
    CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file 'C:\Program Files\Microsoft SQL Server\MSSQL10.MICROBIZWIZ\MSSQL\DATA\Insectafly.mdf'. (Microsoft SQL Server, Error: 5123)
    
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.00.2531&EvtSrc=MSSQLServer&EvtID=5123&LinkId=20476
    
    ------------------------------
    BUTTONS:
    
    OK
    ------------------------------
    
    Tuesday, August 24, 2010 8:32 PM

Answers

  • Yes, this is weird. Try stopping SQL Server service. 
    Premature optimization is the root of all evil in programming. (c) by Donald Knuth

    Naomi Nosonovsky, Sr. Programmer-Analyst

    My blog
    • Marked as answer by hfinny Sunday, August 29, 2010 1:29 PM
    Wednesday, August 25, 2010 10:53 PM
    Answerer

All replies

  • Try closing SSMS and Visual Studio and then re-try. Make also sure that you select master database when you're trying to attach the database.
    Premature optimization is the root of all evil in programming. (c) by Donald Knuth

    Naomi Nosonovsky, Sr. Programmer-Analyst

    My blog
    Tuesday, August 24, 2010 9:42 PM
    Answerer
  • Thanks, I had the same idea in closing down VS and SSMS, as sometimes they hang up.  I right-click on Databases in SSMS, then select attach, the click the Add button.  From there I navigate to the folder with the database, select it and hit Ok.  That is when I receive the error.  I am not sure where I would select master database.  Can you explain?

    thanks

    Tuesday, August 24, 2010 10:37 PM
  • In the New Query dialog type

    USE master 

    and then execute this script.

    Then, instead of running the Attach from the interface, try to generate script and try running that script. 

    Also, is this file in the local folder to which SQL Server has access? If you have SQL Server installed locally, try using some simple folder, such as 

    c:\SQL Databases

    Try copying the mdb/ldb and other files there using Windows Explorer. If you would not be able to copy the files, then they are really used by some process.

    In this case you may need to re-start your PC.


    Premature optimization is the root of all evil in programming. (c) by Donald Knuth

    Naomi Nosonovsky, Sr. Programmer-Analyst

    My blog
    Tuesday, August 24, 2010 10:45 PM
    Answerer
  • Can you please provide below details...

     @OS Details?

     @SQL Server Version with Service pack?

     @User Credential trying to attach the DB? (Admin/ user)

     @DB File Located disk type? (Win Local drive/Shared drive)

     

     


    - MS (We are what we repeatedly do, Excellence, then, is not an act, but a habit.)
    Wednesday, August 25, 2010 6:50 AM
  • Thanks.  I tried to copy the DB file to a new folder I created in C:SQL Databases.  I was unable to copy as a received a pop-up that informed me that the file was in use.  I tried this after restarting the computer, without opening SSMS or VS.  Not sure why the file is hung up in use after a computer restart.  But for some unknown reason it is.
    Wednesday, August 25, 2010 8:36 PM
  • Hi,

    The OS is Vista, the SQL version is 2008 Developer, I tried started SSMS as Administrator, and the file is local (on my own computer).  I am not sure if I need to set a permission somewhere or what the problem might be.  In any event, I can do so, meaning my system in not on a network.

    Wednesday, August 25, 2010 8:40 PM
  • Yes, this is weird. Try stopping SQL Server service. 
    Premature optimization is the root of all evil in programming. (c) by Donald Knuth

    Naomi Nosonovsky, Sr. Programmer-Analyst

    My blog
    • Marked as answer by hfinny Sunday, August 29, 2010 1:29 PM
    Wednesday, August 25, 2010 10:53 PM
    Answerer
  • HI,

     R u rying to attach the DB from one instance to another which already in Use?.

     

    Error clears states its due NDF file is in use.

     

    If u want to attach the Db that is in use. follow the steps

    1) Dettach the DB u want attach from sql server.

    2) Copy that MDf file to another folder.

    3) Now attach that copied MDf file to another instance u want.

    Don't forget to attach the orginal Db you have dettach again to same instance.

    Thursday, August 26, 2010 2:15 PM