Solved

Move the Microsoft SQL database to the mounted disk.

Posted on 2014-02-24
7
299 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
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 300 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 24

Expert Comment

by:lionelmm
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 24

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 24

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now