a severity level of * indicates that data corruption may exist . Possible causes include broken page chains, corrupted IAM, or Invalid entries in the Sys.objects catalog view of the object. These errors are usually caused by hardware or disk device driver failure.
MS SQL Server provides many commands for database repair, which can be attempted when the MS SQL Server database is questioned or if there is no way to complete the read.
1. DBCC CHECKDB
Restarting the server
UseMasterDeclare @databasename varchar(255) Set @databasename=' name of the database entity to be repaired 'execsp_dboption@databasenameN Single', N ' true ' – Set the target data base to single-user stateDBCCCheckdb@databasename, Repair_allow_data_loss)DBCCCheckdb@databasename, Repair_rebuild)execsp_dboption@databasenameN Single', N ' false ' – Set the target data base to multi-user state
sql2012 Modifying a single-user state statement for the target database
ALTER DATABASE dt_cms_ojj SET single_user with ROLLBACK IMMEDIATE;
sql2012 Modifying a single-user state statement for the target database
Alter Database Dt_cms_ojj Set Multi_user
Then execute the SQL Server Data Repair command DBCC CHECKDB (' name of the database entity that needs to be repaired ') to check whether the database still has errors. Note: Repair may result in loss of some data.
2. DBCC checktable
If the DBCC CHECKDB check still has errors, you can use DBCC CHECKTABLE to fix them.
Usethe name of the database entity that needs to be repairedDeclare @dbname varchar(255)Set @dbname=' name of the database entity to be repaired 'execsp_dboption@dbname,’ Single User’,'true ' DBCC CHECKTABLE (' name of the data table to be repaired ', repair_allow_data_loss) DBCC CHECKTABLE (' name of the data table to be repaired ', repair_rebuild)-Put ' The name of the data table that needs to be repaired is changed to execute SQL Server Data Repair command DBCC CHECKDB times the name of the wrong data table exec sp_dboption @dbname, ' Single user ','False
3. Other Common repair commands
DBCC Dbreindex Rebuilding one or more indexes of a table in a specified database
Usage: DBCC dbreindex (table name, ') fixes all indexes on this table.
Explanation of SQL Server Data Repair command DBCC usage