SQL Server Data Recovery Process notes

Source: Internet
Author: User

In April 5, SQL Server 2000 database Asia was required to obtain only MDF and LDF files because of Hard Disk damage.
I thought that only the MDF file was obtained.
Exec sp_attach_single_file_db @ dbname = n' asiadb01 ',
@ Physname = n'd:/Microsoft SQL Server/MSSQL/data/asiadb01_data.mdf'
But the prompt is unsuccessful;
Try again to build a database first, then separate it, delete the log file, and then execute the mounting operation.

Later, the log file was found and mounted successfully. However, the database was displayed as read-only. The MDF was copied from the CD and the file attribute was read-only, after modification, the read-only attribute of the database can be removed.

Exec sp_attach_db @ dbname = n' asiadb01 ',
@ Filename1 = n'd:/Microsoft SQL Server/MSSQL/data/asiadb01_data.mdf ',
@ Filename2 = n'd:/Microsoft SQL Server/MSSQL/data/asiadb01_log.ldf'

Later, the Asia application was executed, and the login process was correct. However, the adodc1 error was displayed when the order number was called in the program. The [SQL Server] [ODBC] data connection was interrupted, and I thought it was
Application Problems, because the operating system, database server, and application are all newly installed. The application also reports unregistered control errors from time to time.
Because the Hong Kong software supplier Customer Service staff has been working along this line of thinking to solve the problem, busy for a day without any results.

The next day I installed the application on my computer, used the SQL Server event probe to monitor the SQL statements executed when an error occurred, and copied them to the query analyzer for execution. The following problems were found:

Select zkakeh2.kasrden from zkakeh2

Server: Message 21, level 24, status 1, Row 1
Warning: critical error 823 occurred at 04 5 2005 pm

Connection interrupted

Set rowcount 100000;
Select Top 1000 * From zkakeh2: No problem. However, when you query 10000 records, the connection is interrupted. In the beginning, we can judge that a problem has occurred in the database.

After DBCC checklist and database are used, a large number of errors occur.
DBCC checktable ('zkakeh2 ')
DBCC checkdb ('asadb01 ')

The repair option cannot be used.
DBCC checkdb ('asadb01', repair_rebuild)
DBCC checkdb ('asadb01 ', repair_allow_data_loss)

No way. You can create a new database with the same object first, and then use DTS to import all the data from the bad database. the data import failed because several tables entered data when the database was rebuilt,
Clear data first:
Truncate table kparam3;
Truncate table zhito;
Truncate table zmoney;
Truncate table ztrno;
Re-import the data of the four tables. Everything is OK.
Check with DBCC, pass, and finally see a glimpse.
Reset the application ODBC and connect it with the program! Thank God.

Summary:
The database should be backed up in a timely manner (including log backup). In this case, only the MDF and LDF files rescued after the hard disk breaks down because of the lack of backup files, which costs a lot of money. when this problem occurs,
We should first consider the database, rather than the front-end application issues :)

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.