- Run the following statement.
ALTER DATABASE database_name SET OFFLINE;
- Move the file or files to the new location.
- For each file moved, run the following statement.
USE master GO ALTER DATABASE AdventureWorks2012 MODIFY FILE ( NAME = AdventureWorks2012_Data, FILENAME = 'C:\Disk2\AdventureWorks2012_Data.mdf'); -- New file path USE master GO ALTER DATABASE AdventureWorks2012 MODIFY FILE ( NAME = AdventureWorks2012_Log, FILENAME = 'C:\Disk2\AdventureWorks2012_log.ldf'); -- New file path
- Run the following statement.
ALTER DATABASE database_name SET ONLINE;
- Verify the file change by running the following query.
SELECT name, physical_name AS CurrentLocation, state_desc FROM sys.master_files WHERE database_id = DB_ID(N'<database_name>');
This blog is created to add all the information and experiences that I have learnt while working on MS sql server as a DBA. The blog is also updated frequently with the real world problem that I encounter hands on at work and the resolutions to resolve them. I hope this blog will be of some use to you and you will revisit. Thank you for stopping by and you are welcome to leave comments.
Friday, June 24, 2016
Move a user databases
To move a data or log file as part of a planned relocation, follow these steps:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment