Tuesday, January 19, 2016

Move MSSQL database file path

The solution if found at: https://msdn.microsoft.com/en-us/library/ms345408.aspx


The steps are:

1) Change file path:
ALTER DATABASE [db_name] MODIFY FILE ( NAME = [db_logic_name], FILENAME = '[new path]' )
2) Stop MSSQL server.
3) Move the file.
4) Restart MSSQL server.

That's all. Now you can check status by:

SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'[db_name]');

No comments:

Blog Archive

Followers