Error on attaching an SQL Server database

Certain times we get an error while attaching an mdf file saying,

The file “D:\DataBaseFile.mdf” is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
Could not open new database ‘D:\DataBaseFile.mdf’. CREATE DATABASE is aborted.


This is because MSSQL Server does not support reading from a compressed drive.

When the mdf file is created on Vista it is in a compressed version. So when trying to use the same file on Win XP which is an uncompressed disc this problem occurs. The solution to this is marking the mdf and ldf file as uncompressed. Follow the following steps,
1. Right-click the .mdf file and select the properties menu.
2. From the Properties dialog box select the Advanced button
4. From the Advanced Dialog un-tick the “Compress Contents To Save Disk Space check box”

Do the same thing for the .ldf file.

Try attaching the database now and it should work.

Have fun.

Tags: ,

Leave a Reply