Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 change file location

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-05-29 : 05:36:55
Hi,
One of the databases in Dev is stored in C drive.
How can I place it in D drive instead please?
Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-05-29 : 05:44:45
I would do it via backup and restore.
You can google for "sql server restore database with move"


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-05-29 : 06:35:57
Thanks
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-06-11 : 17:43:36
You can also use the ALTER DATABASE statement to define the new file location following these steps:
1) ALTER DATABASE to define the new file location(s)[CODE]ALTER DATABASE MyDatabase MODIFY FILE (NAME = logical_name, FILENAME = 'D:\SqlData\PhysicalFilename.ndf')[/CODE]
2) Stop the SQL Service
3) Physically move the database files to the new location
4) Restart the SQL Service
5) Verify the desired result
6) Physically delete the ORIGINAL data file(s) (Optional, but c'mon)
7) Make a backup of MASTER database (Optional, but you'll be glad you did!!!)


=================================================
There is a foolish corner in the brain of the wisest man. -Aristotle, philosopher (384-322 BCE)
Go to Top of Page
   

- Advertisement -