July 29, 2014 at 6:49 pm
I had SQL Server on a Server and the OS went bad and I had to reinstall the OS. In doing so, the wrong disk was used to install the OS and Formated the disk with the SQL Data. I did not install anything on there, so I was able to restore the SQL db's to another disk with recover software. Now I am trying to reattach the db's but I get an error msg "Attach databases failed for...." "Database ... cannot be upgraded because it is read-only or has read-only files. make the database or files writeable, and rerun recovery. ... Error: 3415"
How can I reattach these files?
July 30, 2014 at 1:09 am
Remove the Read-Only flag on the NTFS permissions for the MDF file (& LDF).
July 30, 2014 at 5:04 am
That's the first thing I tried, no cigar.
July 30, 2014 at 5:33 am
Make sure the files aren't read-only, make sure the folder isn't read-only (check parent folder too). Make sure that the SQL Server service account has full permissions on the files and folder.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 30, 2014 at 8:23 am
what is the sql server service acct (default)?
July 30, 2014 at 8:27 am
GrassHopper (7/30/2014)
what is the sql server service acct (default)?
Whatever you set it to!!
Open sql server configuration manager on the server and check the acct in use for the sql and its agent service
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
July 30, 2014 at 10:09 am
that did not work. Running a recovery application on the file and it is recovering the db. It must be corrupt.
July 30, 2014 at 12:25 pm
GrassHopper (7/30/2014)
that did not work. Running a recovery application on the file and it is recovering the db. It must be corrupt.
No. Corrupt databases do not give that error.
Did you ensure that the folder isn't read only anywhere? That the file isn't? That the permissions are correct?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 30, 2014 at 3:01 pm
Yes, checked rights and read only checkbox on folder and on file. I even moved the sql files to the default location for sql data files.
July 30, 2014 at 3:02 pm
2 db's were able to attach, the others did not and they are all in the same folder.
July 30, 2014 at 6:35 pm
Try this, open powershell,
cd databasefilelocation
$Acl = Get-Acl "workingdatafile.mdf"
Set-Acl "nonworkingdatafile.mdf" $Acl
July 31, 2014 at 10:03 am
I have windows 2008 R2 and I don't see powershell anywhere and can't find it to install it on my OS. It is 32 bit. Is it already installed?
July 31, 2014 at 11:44 am
Found it and installed it. I have to reboot the server, so I will have to wait till end of the day to reboot. I'll try it later. thanks.
July 31, 2014 at 2:09 pm
Before I do this, what exactly does this do?
July 31, 2014 at 7:32 pm
It will copy the NTFS permissions (known as an Access Control List or ACL) from a working MDF file (where the permissions are correct and work with SQL) to the non-working MDF (the one reporting read only errors). It's the same as manually copying the permissions from Security tab of the file. It's just a way to rule out permissions as an issue.
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply