0

I have my MS SQL server installed at a virtual Hard disk (D:) as my machine under Win 11 environment. The data file attached with my database is located at the same installation folder. I want to move my database' data files to another disk with more free space. I have copied the .mdf and .ldf files to the new path physically.

However, it prompted the following error:

MODIFY FILE failed. File 'MyDataBase' does not exist.
MODIFY FILE failed. File 'MyDataBase_Log' does not exist.

When i check the disk manager, my SQL is located at Disk 0, while the other disks are located in Disk 1. Is it because of the VHD which SQL is installed at and thus it is not able to identify the files in another disk?

i have use the follow script in SQL:

USE master;
GO

ALTER DATABASE MyDataBase   
    MODIFY FILE ( NAME = MyDataBase,   
                  FILENAME = 'P:\NEW_PATH\MyDataBase.mdf');  
GO

ALTER DATABASE MyDataBase   
    MODIFY FILE ( NAME = MyDataBase_Log,   
                  FILENAME = 'P:\NEW_PATH\MyDataBase_Log.ldf');  
GO
1

1 Answer 1

0

Ensure new folder security permits access to sql service account. I would detach / reattach the database, copying the files between actions. Delete old files once confirmed successful re-attaching of the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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