Home  >  Article  >  Database  >  SQL Server里附加数据库出错的解决方法_MySQL

SQL Server里附加数据库出错的解决方法_MySQL

WBOY
WBOYOriginal
2016-06-01 13:51:091449browse

bitsCN.com

     在QA里执行sp_attach_db或者sp_attach_single_file_db,出现提示:错误1813:未能打开新数据库’dbname’,create database 将终止。设备激活错误。物理文件名’d:sql servermssqldatadbname _log.ldf’可能有误!

 

后来到baidu里找到相关的方法,不错,问题解决了。

 

按下面的步骤处理:

 

1.新建一个同名的数据库2.再停掉sqlserver服务(注意不要分离数据库)

 

3.用原数据库的数据文件覆盖掉这个新建的数据库4.再重启sqlserver服务

 

5.此时打开企业管理器时会出现置疑,先不管,执行下面的语句(注意修改其中的数据库名)6.完成后一般就可以访问数据库中的数据了。这时,数据库本身一般还有问题,解决办法是:利用数据库的脚本创建一个新的数据库,然后通过DTS将数据导进去就行了

 

 

use master

go

sp_configure ’allow updates’,1 reconfigure with override

go

update sysdatabases set status =32768 where name=’置疑的数据库名’

go

sp_dboption ’置疑的数据库名’, ’single user’, ’true’

go

dbcc checkdb(’置疑的数据库名’)

go

update sysdatabases set status =28 where name=’置疑的数据库名’

go

sp_configure ’allow updates’, 0 reconfigure with override

go

sp_dboption ’置疑的数据库名’, ’single user’, ’false’

go

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn