How to recover when the database file is corrupted
Welcome everyone to communicate with me: Xiaobai enhydra_boy@tom.com
Welcome to reprint, please keep this statement, thank you!
In the SQL Server2000, what should we do if the database file (non-system database file) encounters an error. The following is the note before the author. Only the database of non-MASTER, MSDB.
described as follows:
1 Construction of a test database TEST (Database type is complete) 2 built a table, insertion point record Create Table A (C1 varchar (2)) Go Insert Into a Values ('AA') Go Insert Into a Values ('bb') Go 3 full backup, to the file test_1.bak4 in making something insert into a values ('cc') Go Create Table B (C1 Int) Go Insert Into B Values (1) Go Insert Into B Values (2) Go5 Shutdown Database Server 6 edit database file test_data.mdf with UltraEdit, and then modify the point byte content, which is equivalent to a deadly damage. 7 Start the database, and run the Enterprise Manager, click on the database, see TEST to become gray, and display it. 8 Run isql -slocalhost -usa -p1> backup log test to disk = 'd: / program files / microsoft sql server / mssql / backup / test_2.bak' with no_truncate2> Go has processed 2 pages, these pages belong to database 'Test 'File' test_log '(on file 1). The Backup log operation has been successfully handled 2 pages, which took 0.111 seconds (0.087 MB / sec).
9 Recover the oldest full backup 1> Restore Database test from disk = 'd: / program files / microsoft SQL Server / MSSQL / Backup / Test_1.bak' with Norecovery2> Go has processed 96 pages, these pages belong to database 'Test 'The file' Test_Data '(on the file 1). Process 1 pages, these pages are file 'test_log' (on file 1). Restore Database Successfully handles 97 pages, spent 0.107 seconds (7.368 MB / sec).
10 Restore the nearest log 1> Restore log test from disk = 'd: / program files / microsoft SQL Server / MSSQL / Backup / Test_2.bak' with recovery2> Go has processed 2 pages, these pages are files 'test' files 'Test_log' (on the file 1). Restore log operations have been successfully processed by 2 pages and spent 0.056 seconds (0.173 MB / sec).
The data has been fully recovered, which can be used. Select * from ago