Answers

Question and Answer:

  Home  MS SQL Server

⟩ How to move database physical files in MS SQL Server?

If you want to move database physical files to a new location, you can use the "ALTER DATABASE" statements to bring the database offline, and link it to the files at the new location. The following tutorial gives you a good example:

ALTER DATABASE GlobalGuideLine SET ONLINE

GO

USE GlobalGuideLine

GO

CREATE TABLE Links (Name NVARCHAR(32))

GO

ALTER DATABASE GlobalGuideLine SET OFFLINE

GO

Now it is safe to move the database physical files to a new location:

1. Run Windows Explorer

2. Create a new directory: c: empdata

3. Drag and drop c: empGlobalGuideLine.mdf to c: empdata

3. Drag and drop c: empGlobalGuideLine.mdf to c: empdata

Go back to the SQL client program and run:

ALTER DATABASE GlobalGuideLine

MODIFY FILE (NAME = GlobalGuideLineDB,

FILENAME = 'C: empdataGlobalGuideLineDB.mdf')

GO

 156 views

More Questions for you: