No database log file database recovery method two

 

method one

1. Create a database with the same name

2. And then turning off sql server (be careful not to separate database)

3. To overwrite the new database using the original database data files

4. restart sql server

The question appears when you open Enterprise Manager, the first matter, execute the following statement (note modify the database name them)

6. After general can access the data in the database, and then, the database itself but also the general problem, the solution is to use
to create a new database script database and data into the guide on the trip.

USE MASTER
GO

SP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE
GO

UPDATE SYSDATABASES SET STATUS = 32768 WHERE NAME = ' doubt the database name'
Go

sp_dboption 'question database name', 'User SINGLE', 'to true'
Go

DBCC CHECKDB ( 'doubt the database name')
Go

update sysdatabases set status = 28 where name = ' database name doubt'
Go

sp_configure 'allow updates', 0 reconfigure with override
Go

sp_dboption 'question database name', 'User SINGLE', 'to false'
Go

Method Two

It began
yesterday, the system administrator told me that a lack of disk space our internal application database resides. I noticed that the database file XXX_Data.ldf event log file has grown to 3GB, so I decided to shrink the log file. After a database shrink operation failed, I made a stupid mistake largest and most since entering the industry since: even removed a log file! Then I saw all the articles dealt resume database have said: "In any case we must ensure that the database log file exists, it is essential", and even Microsoft even has a KB article about how to rely on log files to recover the database. I really do not know how to think my time? !

Erupted bad! Rom database, Enterprise Manager next to it says "(doubt)." And the most terrible, this database has never been backed up. The only thing I find is that six months before migrating to another database server, application'd use, but far fewer records, tables and stored procedures. I really hope this is just a nightmare!

No effect recovery process
additional database
when _Rambo have said there is no activity log is deleted log files, can do to recover:

1, was isolated doubt database, can use the sp_detach_db
2, additional databases can be used sp_attach_single_file_db

But, unfortunately, after the execution, SQL Server question does not match the data files and log files, it can not be attached database data files.

DTS data export
can not, can not read the XXX databases, DTS Wizard reports that "initial context error has occurred."

Emergency mode
Yihong Gong child talked about no logs for recovery, you can do this:

1, the database is set to emergency mode

2, re-establish a log file

3, the SQL Server restart

4, the database is arranged to apply single-user mode

5, do DBCC CHECKDB

6, if there is no big problem you can put the database state changed back, remember do not forget to turn off the option to modify the system tables

 

I practice a bit, the data file database applications to remove, re-establish a database of the same name XXX, then stopped SQL service, the original data file is then covered back. Then, follow the steps Yihong Gong child go.

However, unfortunately, in addition to the second step, other steps very successful. Unfortunately, after restarting SQL Server, the database application is still doubt!

But let me good news is that, after doing so, it touches can Select data, let me out big breath. But, when the component uses the database, the report said: "An error occurred: -2147467259 failed to run BEGIN TRANSACTION in database 'XXX' because the database is in bypass recovery mode."

 

All steps of the ultimate success of the recovery
set the database to emergency mode
  stopped the SQL Server service;

  data files XXX_Data.mdf application database is removed;

  XXX re-establish a database of the same name;

  stopped the SQL services;

  the original data file is then covered back;

  run the following statement to the database is set to emergency mode;

  run "Use Master

Go

sp_configure 'allow updates', 1

reconfigure with override

Go”

Results of the:

DBCC execution completed. If DBCC printed error messages, contact your system administrator.

Has configuration options 'allow updates' from 0 to 1. Run the RECONFIGURE statement to install.

 

Then run "update sysdatabases set status = 32768 where name = 'XXX'"

Results of the:

(Effect of the number of rows is 1 line)

 

  restart the SQL Server service;

  run the following statement, the application database is set to Single User mode;

  运行“sp_dboption 'XXX', 'single user', 'true'”

Results of the:

  command completed successfully.

 

  do DBCC CHECKDB;

  run "DBCC CHECKDB ( 'XXX')"

Results of the:

'XXX' in the DBCC results.

'Sysobjects' results of the DBCC.

Object 'sysobjects' 273 lines, which are located in five.

'Sysindexes' results of the DBCC.

Object 'sysindexes' have 202 lines, which are located on page 7.

'Syscolumns' results of the DBCC.

………

 

  run the following statement to turn off the option to modify the system tables;

  run "sp_resetstatus" XXX "

go

sp_configure 'allow updates', 0

reconfigure with override

Go”

Results of the:

Before updating the entry in the database 'XXX' in sysdatabases, the mode = 0, state = 28 (state suspect_bit = 0),

No update any row in sysdatabases, because it has been properly reset mode and status. No errors, no changes were made.

DBCC execution completed. If DBCC printed error messages, contact your system administrator.

Has configuration options 'allow updates' from 1 to 0. Run the RECONFIGURE statement to install.

 

  re-establish another database XXX.Lost;

DTS Export Wizard
  run the DTS Export Wizard;

  EmergencyMode selected copy source database XXX, into XXX.Lost;

  select "Copy between SQL Server database objects and data," tried many times, it seems not just copied all the table structure, but there is no data, no views and stored procedures and DTS Wizard final report copy failed;

  so in the end select "copy from the source database tables and views," but later found that this part of the table always only be copied records;

  then select the "specified by a query data to be transmitted", which lack table records, to which the guide;

  views and stored procedures are executed to add SQL statements.

 

  In this way, XXX.Lost database can replace the original application database.
 

Reproduced in: https: //www.cnblogs.com/Spring/archive/2005/06/01/165991.html

Guess you like

Origin blog.csdn.net/weixin_34343689/article/details/93932366