?
Solved

Move the Microsoft SQL database to the mounted disk.

Posted on 2014-02-24
7
Medium Priority
?
307 Views
Last Modified: 2014-03-05
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
Iwan
0
Comment
Question by:iwantam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 39882879
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:

http://technet.microsoft.com/en-us/library/ms190794(v=sql.90).aspx
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 900 total points
ID: 39883367
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)
0
 

Author Comment

by:iwantam
ID: 39884827
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.

Regards,

Iwan Tamimi
0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
LVL 25

Expert Comment

by:Lionel MM
ID: 39885440
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.
0
 
LVL 25

Expert Comment

by:DBAduck - Ben Miller
ID: 39887450
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.
0
 

Author Comment

by:iwantam
ID: 39887966
dbaduck,

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.

Regards,
Iwan
0
 
LVL 25

Expert Comment

by:DBAduck - Ben Miller
ID: 39906187
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.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question