Move database file

Problem: How to Move a database file

Solution:

4 step process

ALTER DATABASE database_name SET OFFLINE;
ALTER DATABASE database_name MODIFY FILE ( NAME = file_logical_name, FILENAME = ‘new_location’ );
ALTER DATABASE database_name SET ONLINE;

Check:

SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N’database_name’);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: