Solved

Move the Microsoft SQL database to the mounted disk.

Posted on 2014-02-24
7
305 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 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

627 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