-- 1. set DB offline:
ALTER DATABASE MyDataBase SET OFFLINE;
-- 2. move the files
ALTER DATABASE MyDataBase MODIFY FILE ( NAME = 'MyBbFile', FILENAME = 'E:\SQL\Data\MyBbFile.mdf' );
ALTER DATABASE MyDataBase MODIFY FILE ( NAME = 'MyBbFile_log', FILENAME = 'E:\SQL\Log\MyBbFile_log.ldf' );
ALTER DATABASE MyDataBase MODIFY FILE ( NAME = 'MyBbFile_BLOBStorage', FILENAME = 'E:\SQL\BLOB\MyBbFile.ndf' );
-- 3. copy-paste the files to the new folder (via Windows)
-- 4. set DB online:
ALTER DATABASE MyDataBase SET ONLINE;
-- get data of the DB files:
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'MyDataBase');
No comments:
Post a Comment