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.
Author |
Topic |
Hayduke1219
Starting Member
2 Posts |
Posted - 2008-10-18 : 03:23:13
|
I have a database on SQL 2005 Express, where the mdf and ldf files were originally on the C drive. The log file was roughly 16G, and the db was ~800M. I wanted to move the mdf and ldf files to a different physical drive on the server which has more space. Prior to detaching the database, I ran the following script to shrink the db and log: BACKUP LOG MyDB WITH NO_LOG DBCC SHRINKFILE (MyDB_Log, 10, TRUNCATEONLY) DBCC SHRINKDATABASE (MyDB, 10) DBCC SHRINKFILE (MyDB_Data, 10) DBCC SHRINKFILE (MyDB_Log, 10)This appeared to work OK, and the filesizes were reduced. However, the roughly 16G from the ldf does NOT show as free space on the C drive.I then detached the database, and attempted to move the mdf and ldf files to the destination drive. However, when I attempt to move the files, I get a Windows error "Cannot copy MyDB: Access is denied. Make sure the disk is not full or write-protected and that the file is not currently in use."It seems like MSSQL is still somehow using the mdf and ldf.How can I "unlock" the files so that I can move them to the destination drive? Any guidance would be greatly appreciated. |
|
Hayduke1219
Starting Member
2 Posts |
Posted - 2008-10-18 : 13:09:09
|
As it turned out, I was able to move the mdf and ldf files when logged in as administrator. After they were moved, I was also able to reattach the database--also while logged in as administrator. |
 |
|
|
|
|
|
|