How to move SQL server database to another drive

Hossam 45 Reputation points
2023-02-03T12:00:47.7266667+00:00

Hi

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.
14,159 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 113.7K Reputation points MVP
    2023-02-04T10:08:58.36+00:00

    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,171 Reputation points
    2023-02-03T12:09:32.7+00:00

  2. Olaf Helper 45,366 Reputation points
    2023-02-03T12:43:03.38+00:00

    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 45 Reputation points
    2023-02-04T08:42:09.9266667+00:00

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.