SQL Server里附加数据库出错的解决方法_MySQL
Jun 01, 2016 pm 01:51 PMbitsCN.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

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How does Go language implement the addition, deletion, modification and query operations of the database?

What should I do if there is no sound in the system after win11 update? How to solve the problem of no sound in win11 device

Samsung will provide displays for Microsoft's MR headsets, and the devices are expected to be lighter and have clearer displays

Detailed tutorial on establishing a database connection using MySQLi in PHP

How does Hibernate implement polymorphic mapping?

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos

How to stop your iPad from ringing when your iPhone rings

An in-depth analysis of how HTML reads the database
