USE master; DECLARE @databasename VARCHAR(255); SET @databasename = 'BenlaiTask'; ALTER DATABASE BenlaiTask SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DBCC CHECKDB(@databasename,REPAIR_ALLOW_DATA_LOSS); DBCC CHECKDB(@databasename,REPAIR_REBUILD); ALTER DATABASE BenlaiTask SET MULTI_USER WITH ROLLBACK IMMEDIATE;