When using the database, some small errors may occur in the database due to power failure or other reasons. For example, the retrieval of some tables is particularly slow and the data that meets the conditions cannot be found.
The reason for these problems is that the database is damaged or the index is incomplete.
In access, there is a function to fix the database to solve this problem. In SQL Enterprise Manager, this function is not available and should be completed using statements, the following describes how to use SQL statements to fix databases. Note that all users must be disconnected during the following operations:
Usemaster
Go
Sp_dboption 'your database name', 'singleuser', 'true'
Go
Dbcccheckdb ('your database name', repair_rebuild)
Go
Use your database name
Go
Execsp_msforeachtable 'dbccchecktable (''? '', Repair_rebuild )'
Go
Sp_dboption 'your database name', 'singleuser', 'false'
Go