Saturday, August 27, 2016

Move Database File from One Location to Another

--Move Database Files
--Step 1 Find out files you want to move
select DB_NAME(database_id) DBName,name LogicalName, physical_name CurrentLocation from sys.master_files

--Step 2 Run below command and update database name, logical file name and new location.
alter database DBName set single_user with rollback immediate
alter database DBName set multi_user
ALTER DATABASE DBName set offline
ALTER DATABASE DBName MODIFY FILE ( NAME = LogicalName, FILENAME = 'T:\Data\DBName_1.ndf' );  --New Path in place of Z drive
--step 3 Move files physically from old location to new location ctrl + X and ctrl + V
--step 4 bring database online
ALTER DATABASE DBName set online

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home