Try the database to be marked as a restoring processing mode __ Database

Source: Internet
Author: User
Tags microsoft sql server microsoft sql server 2005

How to attempt a database to be marked as restoring

/****

By select left (' Claro ', 2), in Xian, 2009-03-27 00:29:23.450

Microsoft SQL Server 2005-9.00.1406.00

(Intel X86)

Mar 3 2007 18:40:02

Copyright (c) 1988-2005 Microsoft Corporation

Enterprise Edition on Windows NT 5.2 (Build 3790:service Pack 2)

****/

Use [master]

Go

-->1. Querying database status

Select State_desc,name,user_access_desc from sys.databases where name= ' db '

--state_desc name User_access_desc

--restoring Db Multi_user

-->2. Modify Database state

ALTER DATABASE [Db] SET ONLINE

--Message 5052, Level 16, State 1, line 1th

--The ALTER database is not allowed when the databases are in restoring state.

--Message 5069, Level 16, State 1, line 1th

The--alter DATABASE statement failed.

-->3. Set the database status to Emergency recovery mode

ALTER DATABASE [Db] SET Emergency

--Message 5052, Level 16, State 1, line 1th

--The ALTER database is not allowed when the databases are in restoring state.

--Message 5069, Level 16, State 1, line 1th

The--alter DATABASE statement failed.

-->4. Set database status to Single-user mode

ALTER DATABASE [Db] SET Single_user

--Message 5052, Level 16, State 1, line 1th

--The ALTER database is not allowed when the databases are in restoring state.

--Message 5069, Level 16, State 1, line 1th

The--alter DATABASE statement failed.

-->5.CHECKDB Inspection

DBCC CHECKDB (Db,repair_allow_data_loss)

--Message 927, Level 14, State 2, line 1th

--Cannot open database ' Db '. The database is being restored.

-->6. Trying to continue the restore with a backup set

RESTORE DATABASE [Db] from DISK = N ' C:/db.bak ' with FILE = 1, Nounload, REPLACE, STATS = 10

Go

--13 has been processed.

--22 has been processed.

--31 has been processed.

--40 has been processed.

--54 has been processed.

--63 has been processed.

--72 has been processed.

--81 has been processed.

--90 has been processed.

--100 has been processed.

--176 pages have been processed for database ' db ', file ' db ' (located on file 1).

--2 pages have been processed for database ' Db ', file ' db_LOG ' (located on file 1).

--restore DATABASE successfully processed 178 pages, costing 0.159 seconds (9.125 mb/sec).

-->7. Check Database status

Select State_desc,name,user_access_desc from sys.databases where name= ' db '

--state_desc name User_access_desc

--online Db Multi_user

--This DB database is normal. The way the database is repaired after subsequent attempts to state the database in doubt.

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.