A
A
Alexander2021-03-15 16:12:04
Database administration
Alexander, 2021-03-15 16:12:04

Is it possible to read the data if there are errors and upload them to another database?

After the hard disk crashed, there were problems with the database on SQL 2012. The Astral program (its database itself) stopped starting. I connect SQL Management Studio, do a database scan, get CHECKDB found 244 placement errors and 1 consistency errors in the database . REPAIR_REBUILD did not bring any results, but .. There is a working backup of the database, a month earlier (unfortunately not earlier) and I have a question, is it possible to somehow try to unload the data for the last month from the "broken" database and load it into the working one, but irrelevant? Unless, of course, this data is intact.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail E, 2021-03-15
@Mikhail_E

!I recommend that you first make a physical copy of the database files (mdf, ldf)!
As an option, determine broken tables by ID, and try Checktable on specific tables first Repair_rebuild, if the DBMS answers that the minimum level is REPAIR_ALLOW_DATA_LOSS , then do Checktable(<TablePath>,REPAIR_ALLOW_DATA_LOSS ). The pages of the tables that are paged will be cleared, but those that are not paged should become available for work (part of the data will be lost, but the database should become available for work).
If you determine broken tables by ID - it is problematic (for some reason) you can immediately load on the database:
DBCC CheckDB (<DBNAME>, REPAIR_ALLOW_DATA_LOSS).
Those. the script is something like this:

USE ИмяБД;
GO  
--(Далее выполнять поочереди)
EXEC sp_resetstatus 'ИмяБД'
GO

ALTER DATABASE 'ИмяБД' SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

--Попробовать:
DBCC CHECKALLOC (ИмяБД, REPAIR_REBUILD) WITH NO_INFOMSGS
GO

--Если СУБД сообщит, что для исправления ошибок - минимальный уровень 
--REPAIR_ALLOW_DATA_LOSS тогда:
DBCC CheckDB (ИмяБД, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS
GO

ALTER DATABASE ИмяБД SET MULTI_USER
GO

K
Konstantin Tsvetkov, 2021-03-18
@tsklab

If you were able to connect an up-to-date database, then delete everything that is in the backup from it. Then merge everything into one.
Correct errors as they come in (maybe places with errors will not be needed).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question