--如果附加不成功,用下面的方法:备份数据文件,然后按下面的步骤处理:1.新建一个同名的数据库(数据文件与原来的要一致)2.再停掉sql server(注意不要分离数据库)3.用原数据库的数据文件覆盖掉这个新建的数据库4.再重启sql server5.此时打开企业管理器时会出现置疑,先不管,执行下面的语句(注意修改其中的数据库名)6.完成后一般就可以访问数据库中的数据了,这时,数据库本身一般还要问题,解决办法是,利用 数据库的脚本创建一个新的数据库,并将数据导进去就行了.USE MASTER GOSP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE GOUPDATE SYSDATABASES SET STATUS =32768 WHERE NAME='置疑的数据库名' Gosp_dboption '置疑的数据库名', 'single user', 'true' GoDBCC CHECKDB('置疑的数据库名') Goupdate sysdatabases set status =28 where name='置疑的数据库名' Gosp_configure 'allow updates', 0 reconfigure with override Go sp_dboption '置疑的数据库名', 'single user', 'false' Go
现在删除数据了,又出现以下错误Changed language setting to us_english. Server: Msg 906, Level 22, State 2, Line 1 Could not locate row in sysobjects for system catalog 'Sysobjects' in database 'open2001'. This system catalog should exist in all databases. Run DBCC CHECKTABLE on sysobjects in this database.Connection Broken
下面的示例分离 pubs,然后将 pubs 中的一个文件附加到当前服务器。EXEC sp_detach_db @dbname = 'pubs'
EXEC sp_attach_single_file_db @dbname = 'pubs',
@physname = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf'
,'数据文件名(*.mdf注意要带目录)' --后面可以是用,分隔的该数据库的多个数据文件
数据库的脚本创建一个新的数据库,并将数据导进去就行了.USE MASTER
GOSP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE
GOUPDATE SYSDATABASES SET STATUS =32768 WHERE NAME='置疑的数据库名'
Gosp_dboption '置疑的数据库名', 'single user', 'true'
GoDBCC CHECKDB('置疑的数据库名')
Goupdate sysdatabases set status =28 where name='置疑的数据库名'
Gosp_configure 'allow updates', 0 reconfigure with override
Go sp_dboption '置疑的数据库名', 'single user', 'false'
Go
,'数据文件名(*.mdf注意要带目录)' --后面可以是用,分隔的该数据库的多个数据文件时出现下面错误sp_attach_single_file_db '数据库名'
,'数据文件名(*.mdf注意要带目录)' --后面可以是用,分隔的该数据库的多个数据文件
http://www.pchomes.com/article/2003/2003-10-15/15771.html
Server: Msg 1801, Level 16, State 3, Line 1
Database 'open2001' already exists.
Server: Msg 906, Level 22, State 2, Line 1
Could not locate row in sysobjects for system catalog 'Sysobjects' in database 'open2001'. This system catalog should exist in all databases. Run DBCC CHECKTABLE on sysobjects in this database.Connection Broken
dbcc CHECKTABLE('sysobjects')