?
Solved

HELP!!!  Need to move database from one drive to another on the same server

Posted on 2011-03-15
14
Medium Priority
?
289 Views
Last Modified: 2012-05-11
Hi, I am new to sql server arena, but I have been tasked to setup SQL Server 2005 x64 SP4 on a Server 2008 R2 box, which I have.  I thought I was installing the SQL Server  on the D: drive, but apparently not.  So, when I made the databases for some reason they are in the default location on the C: drive (C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data).  I would rather have them on the D: drive which has several terabytes of space.  (D:\SQLServer\Data).

Also, there are a couple of databases on the D: drive that I would like to move into this D:\SQLServer\Data folder.

What is the process of accomplishing these tasks?

Thanks in advance.


0
Comment
Question by:rsnellman
[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
  • 6
  • 4
  • 2
  • +2
14 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 35138387
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 1800 total points
ID: 35138389
Right click the database select detach, copy the mdf and ldf files to where they need to be.
Right click databases and select attach, browse to the new location
0
 
LVL 13

Assisted Solution

by:devlab2012
devlab2012 earned 200 total points
ID: 35138421
Take a full database of the backup and then restore the database. During restore, choose the new file location.
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:rsnellman
ID: 35138424
Do I need to do this detach process if the database is on the same drive?  (Ex:  I have a database in a folder that I would like to move to a different folder on the same drive.)
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 35138432
Detach is the best way to do it yes. I thought you wanted to move it to the D drive?
0
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 1800 total points
ID: 35138437
To update the default locations after you have done the move:

Right click the SQL server instance and select properties.
Click Database Settings
Change Database default locations.
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35138443
Yes use detach in both cases it is the safest way,
0
 
LVL 14

Expert Comment

by:Daniel_PL
ID: 35138444
You can alter database also:


ALTER DATABASE database_name SET OFFLINE;

ALTER DATABASE <your db name here> MODIFY FILE 
(name=<logical file name>, filename='<path to file>)

--copy your files

ALTER DATABASE database_name SET ONLINE;

Open in new window

0
 

Author Comment

by:rsnellman
ID: 35138449
So, I don't need to backup the database to the new location first?  Did I mention I am new to SQL?
0
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 1800 total points
ID: 35138469
It is wise to do a backup first. It is always wise to do a backup before doing anything, but it doesn't need to be to the new location. You will copy the data and log files to the new location.
0
 

Author Comment

by:rsnellman
ID: 35138489
A couple of the databases are using web applications (IIS).  One is an online calendar and the other is a SharePoint Foundation 2010.
0
 

Author Comment

by:rsnellman
ID: 35138498
Oh, I see.  Thanks for clearing that up jacko72.
0
 

Author Comment

by:rsnellman
ID: 35138700
OK, I have the one database moved.  And it worked like a charm.  Now to figure out the Sharepoint foundation database.
0
 

Author Comment

by:rsnellman
ID: 35141743
OK, I have all the databases moved as desired.

Thanks to all.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

764 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