• Angelindiego (8/7/2012)


    Below is the code I am using to move files from C: drive to F: drive:

    ALTER DATABASE MyDB SET OFFLINE;

    GO

    -- Physically move the file to a new location.

    -- In the following statement, modify the path specified in FILENAME to

    -- the new location of the file on your server.

    ALTER DATABASE MyDB

    MODIFY FILE ( NAME = PrimaryData_log,

    FILENAME = 'F:\MSSQL.1\MSSQL\Data\MyDB _Log.ldf');

    GO

    ALTER DATABASE MyDB

    MODIFY FILE ( NAME = PrimaryData,

    FILENAME = 'F:\MSSQL.1\MSSQL\Data\MyDB.mdf');

    GO

    When I query sys.master_files, it shows that the files are now on the F: drive, but errors out in setting the db back online due to it can't find the files. I look on the server and they are not there. This has to be something simple I am missing....but can't see it. HELP PLEASE!!!

    My head is telling me that it doesn't know where the existing files are....and isn't moving them. ???

    Thank you in advance!!

    Execute the modify statements first, take the db offline and then copy the files to the new location(s).

    Once the db is online remove the old files.

    Have you checked the f drive path has sufficient permissions for the SQL Server service account

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

    "Ya can't make an omelette without breaking just a few eggs" 😉