Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Move SQL Server 2005 database files to a new folder location

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
afifosh
Asked:
afifosh
1 Solution
 
Peter KipropCommented:
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
 
CrowerCommented:
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
 
Ramesh Babu VavillaCommented:
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
 
Anthony PerkinsCommented:
First, can you tell us if they are user databases or system databases or all?
0
 
Alpesh PatelAssistant ConsultantCommented:
Just detach databases

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

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Tackle projects and never again get stuck behind a technical roadblock.
Join Now