There are multiple ways to that you can use to change location of database files, below is the easy way to achieve the goal.
Note: Same procedure can be used to move other files such as ndf and ldf files.
1- Bring the database that you would like to relocate offline
ALTER DATABASE mydatabase SET OFFLINE;
2- Move database files (mdf, ndf, ldfs) manually from your current location to target location.
3- USE master;
GO
ALTER DATABASE mydatabase
MODIFY FILE
(NAME = File_logical_name,FILENAME='D:\SQLAgeDataFiles\mydata.mdf' );
4- ALTER DATABASE mydatabase SET ONLINE;
Note: Same procedure can be used to move other files such as ndf and ldf files.
No comments:
Post a Comment