MSSQL%20Interview%20Questions%20and%20Answers
Question: How to move database physical files in MS SQL Server?Answer: 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 withoutbook SET ONLINE GO USE withoutbook GO CREATE TABLE Links (Name NVARCHAR(32)) GO ALTER DATABASE withoutbook 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:tempdata 3. Drag and drop c:tempwithoutbook.mdf to c:tempdata 3. Drag and drop c:tempwithoutbook.mdf to c:tempdata Go back to the SQL client program and run: ALTER DATABASE withoutbook MODIFY FILE (NAME = withoutbookDB, FILENAME = 'C:tempdatawithoutbookDB.mdf') GO |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is Microsoft SQL Server?
- What is the simplest way to create a new database in MS SQL Server?
- How to delete a database in MS SQL Server?
- How to download and install Microsoft .NET Framework Version 2.0?
- How To Get a List of Columns using the "sp_help" Stored Procedure in MS SQL Server?