Move the Microsoft SQL database to the mounted disk.

Hi All,

I have a SQL database data i.e on E:\SQL_DATA. I wanted to move it to another disk but I cannot change the E:\ drive. One solution in my mind is like following:
1. Shutdown the SQL database
2. Rename the directory from SQL_DATA to SQL_DATA_temp
3. Create again an empty SQL_DATA on the E:\
4. Get a bigger partion/disk, format it and mount the disk on E:\SQL_DATA directory
5. Copy all the the content of  SQL_DATA_tmp directory to the new E:\SQL_DATA
6. Bring up the SQL again.
(the is Windows Server 2003 and the DB is SQL server 2005)

Is that scenario is possible?

Thank you
iwantamSystem AdministratorAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Anthony PerkinsConnect With a Mentor Commented:
Actually it is even simpler than that.  You do not need to detach/attach your database all you need to do is:
1. Set the data files path to the new location using ALTER DATABASE YourDatabaseName MODIFY FILE (...
2. Take the database offline (ALTER DATABASE YourDatabaseName SET OFFLINE)
3. Copy (or if you like living dangerously move) the data files to the new location.
4. Set the database online (ALTER DATABASE YourDatabaseName SET ONLINE)
5. Verify all is fine.
6. If you copied the data files (delete the old files)
Brian CroweDatabase AdministratorCommented:
If I understand you correctly and all you want to do is relocate the .mdf file for your database, then you just need to detach the database, move the file, and reattach the database.

Below is the documented method for doing this for 2005:
iwantamSystem AdministratorAuthor Commented:
Hi All,

Thank you for all  the suggestion.

But I still curious whether my steps could work, just in case the Apps team still want it on the same path. And whether the backup (I am using NetBackup will SQL agent) will still work.


Iwan Tamimi
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Lionel MMSmall Business IT ConsultantCommented:
Your steps won't work--to me it sounds like you think that the SQL DB is somewhat like a folder--it is not. The steps mentioned above are ones you should follow. Moving a database is not like moving a folder.
DBAduck - Ben MillerPrincipal ConsultantCommented:
If you shutdown SQL Server and do what you indicated, it should work just fine as the path to the files will be identical.  The problem you will run into is if you mount a drive to that path, you should not, really should not put the data files in the root of a mounted disk.  You should create a folder one more level deep on a mounted disk and put the files there.

So you can do a hybrid approach using AnthonyPerkins answer just put a disk that is bigger as the mounted copy and alter the database to the new folder with the bigger disk.

So you were close.
iwantamSystem AdministratorAuthor Commented:

I just realize when you said about on the other disk it will be in the root. Yes I never did that I always put in at least 1 directory bellow.  You know at least 1 reason why? Just in case I have to explain.

I am not DBA myslef, looks like as sugested I will follow AnthonyPerkins answer, I will leave the masterdb in the original directory and move the other db to new disk. I will discuss with the DBA first.

Thank you dbaduck, I will let you know.

DBAduck - Ben MillerPrincipal ConsultantCommented:
Just to give you more info on the mount point. If you don't create a folder in the mounted drive root, then it makes it very difficult to put permissions because you would need to put permissions on the drive, and not a folder.

So you would mount a drive in E:\MOUNT.  If you needed permissions to inherit, if you right clicked on E:\MOUNT and put permissions on that hoping to get the permissions to inherit to child objects it would not do it because the mounted drive in E:\MOUNT is not part of E: it is part of a new drive.

So if put a folder in the drive mounted I would have E:\MOUNT\SQLDATA, SQLDATA is the drive so now if I put permissions on SQLDATA then it would be considered the root of the mounted drive.

Hope that makes sense.
All Courses

From novice to tech pro — start learning today.