Database challenges or only MDF file information 1

Source: Internet
Author: User
When ldf is damaged in SQL server 2000, only the recent recovery of mdf encountered an SQL server 2000 file. ldf is damaged, but the mdf is still there, so I tried to recover it, I found some methods online,
Summary

1) back up the original database files (such as test. mdf) to other places in time
2) Stop the server
3) Delete the test. mdf file.
4) re-create a database with the same name as test.
5) Delete the test. ldf file of the newly created test database and overwrite the newly created test. mdf file with the test. mdf file.
6) Start the database server. In this case, the database test status is "Suspect ". At this time, you cannot perform any operations on this database.

. Set the database to allow direct operation of system tables. In SQL Server Enterprise Manager, select the database Server, right-click it, and select "properties". On the "Server Settings" Page, select "allow direct modification to the system directory"

EXEC sp_configure 'Allow Update', 1 reconfigure with override
7) set test to the emergency repair mode.

Update sysdatabases set status =-32768 where dbid = DB_ID ('test ')

At this time, you can see in SQL Server Enterprise Manager that the database is in "read-only, suspicious, offline, and emergency mode" to see the tables in the database, but only the system tables

8) perform the following recovery operations to recreate the database log file.

Dbcc rebuild_log ('test', 'c: \ Program Files \ Microsoft SQL Server \ MSSQL \ Data \ test_log.ldf ')

If the following prompt is displayed during execution:

Server: Message 5030, level 16, status 1, Row 1

The database cannot be locked for this operation.

DBCC execution is complete. If DBCC outputs an error message, contact the system administrator.

This indicates that other programs are using this database. If you opened the system table of the test database using SQL Server Enterprise Manager in step F, you can exit SQL Server Enterprise Manager.

  The prompt for correct execution should be similar:

Warning: the log of the database 'test' has been rebuilt. Transaction consistency is lost. Dbcc checkdb should be run to verify physical consistency. The database must be reset and redundant log files may need to be deleted.

DBCC execution is complete. If DBCC outputs an error message, contact the system administrator.

In SQL Server Enterprise Manager, you can see that the database status is "only for DBO ". Now you can access the user tables in the database.

9) Verify Database Consistency
Dbcc checkdb ('test ')
10) set the database to normal

Sp_dboption 'test', 'dbo use only', 'false'

If no error occurs, Congratulations. Now we can use the recovered database normally.

11) recover the database in emergency mode update sysdatabases set status = 0 where name = @ databasename

12) in the last step, we need to restore the "allow direct modification to the system directory" set in Step 6.

EXEC sp_configure 'Allow Update', 0 reconfigure with override

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.