• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 662
  • Last Modified:

Can't Attach SQL mdf After Moving It

I created a database here:
C:\Program Files (x86)\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA
I detach it, then copy the .mdf and .ldf here: C:\FRCSW
Now when I try to attach the mdf at the new location, I get
"An error occurred when attaching the database(s). Click the hyperlink in the Message column for details".  Then "Unable to open the physical file 'C:\FRCSW\FRCSW_log.ldf.' Operating system error 5: "5(Access is denied)". (Microsoft SQL Server, Error: 5120).

I'm not an advanced SQL guy. I can create the relational tables, write stored procedures, and develope them OK, but I can't seem to deploy them.  I always get stuck on the security and permissions issues.

Thanks in advance
0
LarryZ
Asked:
LarryZ
1 Solution
 
tigin44Commented:
you should modify the current file path of the database files while attaching them. Do you try to attach the db from management studio or by using commands?
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
>> Unable to open the physical file 'C:\FRCSW\FRCSW_log.ldf.' Operating system error 5: "5(Access is denied)

To fix this, just try the steps below:

1. Right click your C:\FRCSW folder
2. Choose Properties and then Permissions..
3. You would be having some builtin SQL Server user groups named SQLServerMSSQLUser$ComputerName$MSSQLSERVER or SQLServerMSSQLUser$ComputerName$InstanceName which would be there along with SQL Server installation.
4. Just add these user groups to C:\FRCSW folder and grant full permissions to that folder for this user group.

This should help you fix it..
0
 
LarryZAuthor Commented:
I use Microsoft SQL Server Management Studio (Express). Right click 'Databases' in Object Explorer, choose 'Attach'. Then in the 'Attach Databases' dialog box, I click 'Add', then in the 'Locate Database Files' dialog box, I point to C:\FRCSW\FRCSW.mdf.  I get the error when I click 'OK'
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
tigin44Commented:
so you should check the permissions on the folder.. follow the steps rrjegan17 described on his post
0
 
LarryZAuthor Commented:
I did what rrjegan17 suggested, and gave the new user Full Control. No luck. I then retarted SQLEXPRESS. Still no luck.
0
 
LarryZAuthor Commented:
If I look at the Properties for the file FRCSW_log.ldf, in the Security tab, I see that SQLServerMSSQLUser$mycomputernamehere$SQLEXPRESS appears in the Group or user name box, and it has Full Control
0
 
LarryZAuthor Commented:
Running Win 7 64-bit, if it matters
0
 
tigin44Commented:
do you have any other copy of the mdf and ldf files? If so pleace replace the files and try to attach the new files...
0
 
LarryZAuthor Commented:
No other copies of the mdf and ldf.  But I can successfuly re-attach the database if I point to the original C:\Program Files (x86)\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA location.
0
 
tigin44Commented:
you should modify the Current File Path sections to locate the new folder... do you do that?
attach.jpg
0
 
LarryZAuthor Commented:
Yes, the path for FRCSW.mdf is C:\FRCSW\FRCSW.mdf and the path for FRCSW_log.ldf is C:\FRCSW\FRCSW_log.ldf.
0
 
tigin44Commented:
do your operating system vista or win7... if so launch Microsoft SQL Server Management Studio as Administrator  and  then attach the db
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
it should be a Permission error... try login as "administrator" and attaching that... surely it is missing the permission to access the folder / file
0
 
LarryZAuthor Commented:
Thank you.  I closed Microsoft SQL Server Management Studio, then right-clicked, selected "Run As Administrator", and I can easily attach the databse now. That worked. I'm a bit confused though. I am logged in to Windows 7 as a user with full administrator rights. And the instance of SQL I am connected to looks like this:
MyComputerName\SQLEXPRESS (SQL Server 10.0.2531 - MyComputerName\MyLoginUsername
The owner of the database is MyComputerName\MyLoginUsername
I need to find a SQL for Dummies book or something that can help me understand the deployment and management of MS SQL.
0
 
LarryZAuthor Commented:
sorry aneeshattingal. Your comment was not yet there when I began accepting tiggin44
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now