Не всичко за мен

Верую: неверник - следствие от прекомерната работа с продукти на Microsoft. Нямам девиз, нямам любимо ядене, пиене, книга, ... Знам какво обичам днес, но това изобщо не важи за утре. Мисля, че горе-долу стана ясно.

Търсене в този блог

вторник, 15 септември 2015 г.

How to check and repair corrupted MS SQL database.

How to check and repair corrupted MS SQL database.

See this link.

In MS SQL Studio run new query:

1. dbcc checkdb(‘DB-NAME’) with no_infomsgs
DB-NAME is a name of your corrupted database. If this is completed without any errors then the database does not need to be repaired.

2. Alter database DB-NAME set SINGLE_USER
Before we begin repairing the database, the database must be set in single user mode.

3. dbcc checkdb(‘DB-NAME’,REPAIR_REBUILD)
There are number of repair model usually we use first REPAIR_REBUILD. When everything is ok go to step 5.e (multi user mode) If not, go to next step.

4. dbcc checkdb(‘DB-NAME’,REPAIR_ALLOW_DATA_LOSS)
This command may cause data loss. When everything is ok go to step 5.e (multi user mode). If not, try something else - restore from backup, recreate database and import data and other db objects.

5. All steps:
a. ALTER DATABASE DB-NAME SET EMERGENCY
b. ALTER DATABASE DB-NAME SET SINGLE_USER
c. DBCC CHECKDB (DB-NAME, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS
d. ALTER DATABASE DB-NAME SET ONLINE
e. ALTER database DB-NAME set MULTI_USER

Description:
a. Set database to emergency mode
b. Set database to single user mode
c. Check database and repair with allow data loss
d. Back database to online mode from emergency mode
e. Set database to multi user mode for normal use

Additional info:
DBCC CHECKTABLE - http://msdn2.microsoft.com/en-us/library/Aa258646
DBCC CHECKDB - http://msdn2.microsoft.com/en-us/library/Aa258278
Changing database to/from single-user mode - http://msdn2.microsoft.com/en-us/library/ms345598.aspx

Няма коментари: