Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Attach/Detach Database Confusion

Author  Topic 

kashif27
Starting Member

7 Posts

Posted - 2009-06-22 : 15:05:17
Hi . . . . .

I created a database in SQL Server 2005 on one machine. On that machine the database was stored in the default "....\Microsoft SQL Server\MSSQL.1\MSSQL\Data" folder. After that I detached the DB and copied it to another machine. On that machine, initially I stored the database file at location other than the default db file location of sql server. When I tried to attach the db file, it gave me teh following error.



TITLE: Microsoft SQL Server Management Studio
------------------------------

Attach database failed for Server 'UZ'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

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

The file "G:\..........\abc.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
Could not open new database 'Dotnet67'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 5118)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=5118&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------



Then I copied the db file on this new machine in the default sql server db file folder "....\Microsoft SQL Server\MSSQL.1\MSSQL\Data" and then when I attached the db, it was attached.

So though my problem is solved, but I do not understand the cause. So could anyone please explain what is the difference and what was the issue.

Thanks


http://www.KashifUmar.com/

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-22 : 15:19:35
Maybe your problem is a compressed file system?
see this:
http://blogs.msdn.com/sanchan/archive/2006/06/04/617585.aspx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

kashif27
Starting Member

7 Posts

Posted - 2009-06-22 : 15:59:19

Yes that's what happened. I am using NTFS file system and the initially I stored the db file on a drive where I applied the "compress drive to save space" option. whereas the default location of sql server db files is on a non-compressed drive.

Thanks fred

http://www.KashifUmar.com/
Go to Top of Page

kashif27
Starting Member

7 Posts

Posted - 2009-06-22 : 16:03:35
Basically I wanted to keep the db file on a drive other than the default operating system drive. But as my other drives are compressed, so I was having problem. But I can still keep the db file on the compressed drive and attach it in sql server. This can be done by going in the properties of the folder that contains the db file. Right click the folder and select properties. Then click Advanced. There un-check the option "Compress contents to save disk space". In this way I am able to keep the db file on a compressed drive and still attach it in sql server.



http://www.KashifUmar.com/
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-22 : 16:35:05
cool


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -