Moving database files to other drive

  • SQL Server Databases present on different servers are present on SAN storage drives. I don't know much about storage drives, but there are some 10 drives on my server(C:drive to N: drive) .Data files(.mdf) are stored on J: drive and I want to move some data files on to other drive(M:drive).

    Can we do sp_detach and sp_attach of these files or is there any other procedure? Is there any other method for SAN storage?

  • Just make sure that no one else is using the database. After which you can use the sp_detach_db and sp_attach_db after the relevant files are moved to their new location.

  • If you're moving several databases make sure you attach in the correct order to maintain the database id's.

     

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

  • I just want to move only one database from that drive to other. other databases will be on the same drive.

    Can I put the database in single user mode?

  • The database being moved needs to be completely offline prior to moving the files. 


    Thanks,

    Lori

  • Detach- Move mdf and ldf files- Attach

  • --> If you're moving several databases make sure you attach in the correct order to maintain the database id's.

    I didnot get that. Like..

    If I am moving DB1(DB1.mdf, DB1.log)

                        DB2(DB2.mdf, DB2_data.ndf, DB2.log)

                        DB3(DB3.mdf, DB3.log)

    If I am moving DB1.mdf from drive D: to driveE: , DB1.log to drive F: and DB2.mdf and DB2.ndf from drive D: to Drive G: etc..

    How can I maintain the database ID's?

     

  • Use the below statement from the master db. Hope this helps !

    use master

    select * from sysdatabases order by dbid


    Get busy living ....or get busy dying....

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

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