I'm trying to deploy an MDF file to my live server, but this also means going from SQL Express 2005 to 2008.

I'm getting the following error in my web page.

Database 'xxx.MDF' cannot be upgraded because it is read-only or has read-only files. Make the database or files writeable, and rerun recovery.

I've tried adding write permission to the IUSR account for the MDF and LDF file, but this doesn't work.

I've read this from MS support, but I don't really understand what I need to do in the context of an MDF file.

Has anyone else come across this and have a solution?



Try attaching the database with SQL Server Management Studio and see if the database upgrade still fails.

  • This worked, but it did lead to another permissions based error when I tried to run the site again. I rechecked permissions and it turned out the app_data folder settings had not been inheritted by both the DB files. Both files need modify permissions given to the IIS_IUSRS group. – Richard Aug 29 '09 at 8:47

If the database is attachable (you dont say if it is or not) then you need to enable writeability in an obsure area in the "properties" of the database. In SQL 2000 this use to be a checkbox setting but in SQL2005 SQL Management Studio Express it is a hard to find "true/false" setting in the db properties.

Also, you obviously should have a .LDF to go along with that right?


If you dont have the LDF you can try the following to attach your DB and see if the upgrade completes:

sp_attach_single_file_db @dbname= 'ENTER_DB_NAME', @physname= 'SOMEDRIVE:\SOME\LOCATION\TO\THE\DATABASEFILE.mdf'

Referenced From: Opening .mdf files

  • I have the LDF file. Sorry for not making that clear. – Richard Aug 29 '09 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.