Move MDF file to new Drive

  • Hi all,

    I need your help,

    i was moving th MDF file to a newly added drive, the steps i follw was:

    1. bring DB ofline

    2. Copy MDF file to new Drive

    3. Bring Db online.

    4. RUN (

    USE master GO ALTER DATABASE TEST MODIFY FILE (NAME = test, FILENAME = 'F:\SQL data\test.mdf') GO)

    5. Restart SQL services.

    now after all this step i found my database goes to suspect mode, can anybody tell me the reason/step i missed and the how to resolve.

    error from sql log:

    The log scan number (856823:4733:134) passed to log scan in database 'UPSInvite' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf).

  • correct sequence is;

    1. ALTER DATABASE TEST MODIFY FILE (NAME = test, FILENAME = 'F:\SQL data\test.mdf')

    2. bring DB offline

    2. Copy MDF file to new Drive

    3. Bring Db online.

    Did copy the file or cut and paste?

    Before going any further and to avoid compounding the issue, what does the following query return?

    select name, physical_name from sys.master_files

    where database_id = db_id('TEST') and file_id = 1

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

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

  • I just copy paste the file, so to avoid any delay while i found a solution

    i change it back to the old location.

  • Also, make sure the SQL Server instance has permissions on the location you are moving the file to!!

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

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

  • thanks for your reply but do you have any idea why my DB went to suspect mode?

  • it went into suspect mode, because sqlserver keeps synchronisation indicators internally. Because you copied the mdf and then brought the db online, the log file got another sync number than the mdf you copied to the new location.

    After restarting sqlserver, these numbers are being checked and it discovered this out of syn situation, so it had to put it in suspect mode.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • also, you don't need to restart the sql server sevices when changing a database file location with alter database, the offline\online will be sufficient!

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

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

  • thanks alot for your kind guidence champions.

  • pujain (10/31/2010)


    thanks alot for your kind guidence champions.

    Read the Jonathan's article[/url]

    For better clear

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply