• 数据库修复

exec sp_dboption 'dbname1','single user',‘true’

dbcc checkdb('dbname1')

dbcc checkdb('dbname1',REPAIR_FAST)
dbcc checkdb('dbname1',REPAIR_REBUILD)
dbcc checkdb('dbname1',REPAIR_ALLOW_DATA_LOSS)
 
exec sp_dboption 'dbname1','single user',‘false’

  • 单表修复

exec sp_dboption 'dbname1','single user',‘true’

dbcc checktable('需要修复的数据表的名称',REPAIR_ALLOW_DATA_LOSS)

dbcc checktable('需要修复的数据表的名称',REPAIR_REBUILD)

exec sp_dboption 'dbname1','single user',‘false’

sql2014

alter database dbname1set SINGLE_USER with ROLLBACK IMMEDIATE
dbcc checkdb('dbname1')

dbcc checkdb('dbname1',REPAIR_FAST)
dbcc checkdb('dbname1',REPAIR_REBUILD)
dbcc checkdb('dbname1',REPAIR_ALLOW_DATA_LOSS)
 
exec sp_dboption 'dbname1','single user','false'
alter database dbname1 set MULTI_USER with ROLLBACK IMMEDIATE

04-28 07:55