October 18, 2008 at 12:14 am
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.
October 18, 2008 at 11:05 am
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.
October 19, 2008 at 11:51 am
Thanks for the update.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply