How to move SQL server database to another drive

Hossam 40 Reputation points


How to move SQL server database to another drive? I tried before by making offline, move physical database file and make online again but it failed, please help

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,262 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 98,901 Reputation points

    I received a message that the destination path is not valid although I mapped the folder in the server and copied the bath exactly, please help

    You cannot use mapped drives, because the drive mapping applies to you user only. SQL Server runs under a different user and does not see that mapping. You need to specify a UNC path like \\SERVER\Share\folder\db.mdf. However, putting database on network drives is not to recommend.

    If you want to move the database to an instance on the physical server, BACKUP/RESTORE is the way to go. And again, you need to use a UNC path.

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Rafael da Rocha 5,071 Reputation points

  2. Olaf Helper 38,861 Reputation points

    but it failed,

    Which error do you get? Have you set the correct location for all database files = MDF + LDF?

    The more save way to move database files is Backup&Restore instead detach/attach.

    0 comments No comments

  3. Hossam 40 Reputation points

    Hello, thanks for your reply, but unfortunately I couldn't backup the data base to our physical server because in the backup process wizard I was asked to select the destination folder but the wizard could only see the local partitions in my machine although I mapped the folder on the server to my machine, please help

    0 comments No comments