For example, the database name is FreeHost.
First, set it to single-user mode, then fix it, and then restore the multi-user mode.
Alter database [FreeHost] SET SINGLE_USER
GO
Dbcc checkdb ('freehost', repair_allow_data_loss) WITH TABLOCK
GO
Alter database [FreeHost] SET MULTI_USER
GO
-- CHECKDB has three parameters:
-- REPAIR_ALLOW_DATA_LOSS
-- Execute all the repairs completed by REPAIR_REBUILD, including allocating and unassigning rows and pages to correct the allocation errors, structure row or page errors, and deleting corrupted text objects. These fixes may cause some data loss. The repair operation can be completed under the user transaction to allow the user to roll back the changes. If the rollback is fixed, the database will still contain errors and the backup should be restored. If an error fix is missing due to the severity of the severity level provided, it will omit any fix that depends on the fix. After the restoration, back up the database.
-- REPAIR_FAST Performs small and time-consuming repair operations, such as fixing the additional keys in non-clustered indexes. These repairs can be completed quickly without the risk of data loss.
-- REPAIR_REBUILD: execute all the repairs completed by REPAIR_FAST, including repairs that require a long period of time (such as re-indexing ). There is no risk of data loss when performing these repairs.
-- Dbcc checkdb ('freehost') with NO_INFOMSGS, PHYSICAL_ONLY