MyDB为待修复的数据库名称
USE
MASTER
GO
SP_CONFIGURE ' ALLOW UPDATES ' , 1 RECONFIGURE WITH OVERRIDE
GO
ALTER DATABASE MyDB SET EMERGENCY
GO
sp_dboption ' MyDB ' , ' single user ' , ' true '
GO
DBCC CHECKDB( ' MyDB ' , ' REPAIR_ALLOW_DATA_LOSS ' )
GO
ALTER DATABASE MyDB SET ONLINE
GO
sp_configure ' allow updates ' , 0 reconfigure with override
GO
sp_dboption ' MyDB ' , ' single user ' , ' false '
GO
GO
SP_CONFIGURE ' ALLOW UPDATES ' , 1 RECONFIGURE WITH OVERRIDE
GO
ALTER DATABASE MyDB SET EMERGENCY
GO
sp_dboption ' MyDB ' , ' single user ' , ' true '
GO
DBCC CHECKDB( ' MyDB ' , ' REPAIR_ALLOW_DATA_LOSS ' )
GO
ALTER DATABASE MyDB SET ONLINE
GO
sp_configure ' allow updates ' , 0 reconfigure with override
GO
sp_dboption ' MyDB ' , ' single user ' , ' false '
GO