SQL Server 2008 R2 recovery move files

Source: Internet
Author: User
Tags mssqlserver management studio sql server management sql server management studio

Friend consultation question, here is a reference step:

Recovery move files

/*

If the database cannot be started, either in suspect mode or in an unrecoverable state, only members of the sysadmin fixed role can move the file.

*/

1. If the instance of SQL Server is started, stop it.

2. Start the SQL Server instance in master only recovery mode by entering one of the following commands at the command prompt.

For the default (MSSQLSERVER) instance, run the following command.

NET START mssqlserver/f/t3608

For a named instance, run the following command.

NET START mssql$instancename/f/t3608

3. For each file you want to move, use the sqlcmd command or SQL Server Management Studio to run the following statement

ALTER DATABASE database_name MODIFY FILE (name = logical_name, FILENAME = ' new_path\os_file_name ');

4. Quit sqlcmd utility or SQL Server Management Studio

5. Stop SQL Server Instance

6. Move a copy to a new location

7. Start SQL Server Instance

NET start MSSQLServer

8. Verify file changes 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> ');

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.