2.创建同名的数据库:
USEmaster
GO
CREATEDATABASEDB_SUSPECT
ON
(NAME=DBNAME_DAT,
FILENAME=C:,
SIZE=10,
FILEGROWTH=5)
LOGON
(NAME=DBNAME_LOG,
FILENAME=g:,
SIZE=5MB,
FILEGROWTH=5MB)
GO
1.设置数据库为告急形式
UseMaster
GO
sp_configureallowupdates,1
reconfigurewithoverride
GO
UPDATEsysdatabasesSETstatus=32768wherename=DB_SUSPECT
GO
2.停失落SQLServer服务:
NETSTOPMSSQLSERVER
3.把原始数据库的数据文件DBNAME_DAT.MDF,DBNAME_LOG.LDF移走:
4.启动SQLServer服务:
NETSTARTMSSQLSERVER
5.从头创建一个同名的数据库DB_SUSPECT;
USEmaster
GO
CREATEDATABASEDB_SUSPECT
ON
(NAME=DBNAME_DAT,
FILENAME=C:,
SIZE=10,
FILEGROWTH=5)
LOGON
(NAME=DBNAME_LOG,
FILENAME=g:,
SIZE=5MB,
FILEGROWTH=5MB)
GO
6.设置数据库运转在单用户的形式:
USEMASTER
GO
ALTERDATABASEDB_SUSPECTSETSINGLE_USER
GO
7.停失落SQL服务:
NETSTOPMSSQLSERVER
8.把本来的数据文件再掩盖返来:
9.启动SQLServer服务:
NETSTARTMSSQLSERVER
10.从头设置SQLSERVER的形态:
USEMASTER
GO
EXECsp_resetstatus"DB_SUSPECT"
11.数据库完全性检测:
DBCCCHECKDB(DB_SUSPECT)
12.恢单数据库为多用户形式:
USEMASTER
GO
ALTERDATABASEDB_SUSPECTSETMULTI_USER
GO
13.恢复SQLSERVER原始的设置:
USEMATER
GO
UPDATEsysdatabasesSETstatus=4194320wherename=DB_SUSPECT
GO
14.设置SQLSERVER不同意更新体系表:
USEMASTER
GO
sp_configureallowupdates,0
reconfigurewithoverride
GO