Detach and Attach error, Help Needed

  • Hi everybody,

    I was able to Detach the database successfully, When I try to copy .mdf file to different location:

    it gives me an error saying:

    Cannot copy <<fname>>: Access is denied.

    Make sure the disk is not full or write-protected

    and that the file is not currently in use.

  • Possible causes:

    AV has the file locked

    The data file is not associated with the database that you detached.

    You don't have modify permissions with your user account to the location where the data file was stored.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • SQLRNNR (3/21/2012)


    Possible causes:

    AV has the file locked

    The data file is not associated with the database that you detached.

    You don't have modify permissions with your user account to the location where the data file was stored.

    do you need modify to copy a file? i thought you only needed read/write to copy a file. though the permissions on the destination is the first thing to check its the easiest.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]

  • I was thinking move the file and not just copy.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Danzz (3/21/2012)


    Hi everybody,

    I was able to Detach the database successfully, When I try to copy .mdf file to different location:

    it gives me an error saying:

    Cannot copy <<fname>>: Access is denied.

    Make sure the disk is not full or write-protected

    and that the file is not currently in use.

    Check the NTFS permissions for the data and log files, the ACLs defined do not provide the access you need. Set the permissions yourself or have your Windows admin do this for you

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • I had admin access on the server,

    I can copy backup files and delete them to that on the drive folder where I wanted to copy the .mdf file using detach attach.

  • Verify that you are trying to copy the correct data files for the database you detached. If the files are correct, then verify the permissions on the files individually.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Danzz (3/21/2012)


    I had admin access on the server,

    sadly, that does not guarantee you have access to the files, it is possible to remove ACLs for a file so that an administrator cannot access them. However, as a server administrator it does gaurantee that if someone hoses the ACL list you can take ownership of the file(s) and reset the ACLs.

    As i said, check the NTFS permissions on the and modify them to grant you access 😉

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • I ran into this issue a hell of a lot in a multi domain environment.

    user machines and accounts where in subdomain.domain.com and servers where in domain.com

    we would detach a database using an account in the subdomain then logon to the server with a root domain account, due to the database being detached by a subdomain account SQL automatically locks that databases files to the user which detached it so only that one user can modify the files. Even though both our sub and root domain accounts where domain admins the root domain account couldn't do anything to the files.

    work around where to detach it as a SQL authentication account or remember to login as the subdomain or detach on the server as the root domain account

  • anthony.green (3/21/2012)


    work around where to detach it as a SQL authentication account or remember to login as the subdomain or detach on the server as the root domain account

    You simply need to reset the NTFS ACLs

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Thanks Perry Whittle & Anthony

    Perry: How do I reset NTFS ACLs?

    Anthony: how did you fix your issue?

  • Danzz (3/21/2012)


    Perry: How do I reset NTFS ACLs?

    Right click the file and select properties then select the security tab. If you don't what you're doing here get your windows admin to help 😉

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

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

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