The processing method of database questioning

Source: Internet
Author: User
Data | database | doubt
Step 1:

Create a new database named the original database name.

Step 2:

Stop SQL Server

Step 3:

Replace the MDF file of the old database with the corresponding MDF file in the new database and delete the LDF file.

Step 4:

Restart the SQL Server service, and then run the following command:

Use Master

Go

sp_configure ' allow updates ', 1

Reconfigure with override

Go

BEGIN Tran

Update sysdatabases Set status = 32768 where name = ' Db_name '

--verify one row is updated before committing

Commit Tran

Step 5:

Stop SQL and then restart the SQL Server service, and then run the following command:

DBCC Traceon (3604)

DBCC rebuild_log (' db_name ', ' c:\mssql7\data\dbxxx_3.ldf ')

Go

Step 6:

Stop SQL and then restart the SQL Server service, and then run:

Use master

Update sysdatabases SET status = 8 where name = ' Db_name '

Go

Sp_configue ' allow updates ', 0

Reconfigure with override

Go

Step 7:

Run DBCC CHECKDB (DB_NAME) to check the integrity of the database

Note: All must replace the real database name.


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.