Solved

Move SQL Server 2005 database files to a new folder location

Posted on 2013-01-09
5
369 Views
Last Modified: 2013-01-24
current path

Path:

    C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
    C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA


i want to create new path in drive D
because i don't have  space in C
0
Comment
Question by:afifosh
5 Comments
 
LVL 6

Expert Comment

by:Peter Kiprop
ID: 38761928
Afifos,

Use the query below to move the database files

use Databasename
go
Alter database Databasename modify file (name = Databasenamefilename , filename = 'D:\Foldername\Databasenamefilename.mdf')
go
Alter database Databasename modify file (name = DatabasenameLogname , filename = 'D:\Foldername\DatabasenameLogname.ldf')
go

You will need to replace the names accordingly for it to work.

Hope it helps.

Pthepebble
0
 
LVL 3

Expert Comment

by:Crower
ID: 38761931
detach your databases. move your files. atach the files on the new location.

http://support.microsoft.com/default.aspx?scid=kb;en-us;224071
0
 
LVL 10

Accepted Solution

by:
sqlservr earned 500 total points
ID: 38762418
ALTER DATABASE TempDB MODIFY FILE
(NAME = dbname, FILENAME = 'c:\mssql\dbname.mdf',SIZE = 3792KB )
GO
ALTER DATABASE TempDB MODIFY FILE
(NAME = dbname_log, FILENAME = 'c:\mssql\dbname_1.ldf',SIZE = 1792KB
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 38765720
First, can you tell us if they are user databases or system databases or all?
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 38765877
Just detach databases

and move mdf/ldf files to new location and attach them again.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

13 Experts available now in Live!

Get 1:1 Help Now