問題:在QA里執(zhí)行sp_attach_db或者sp_attach_single_file_db,出現(xiàn)提示:錯誤1813:未能打開新數(shù)據(jù)庫’dbname’,create database 將終止。設(shè)備激活錯誤。物理文件名’d:sql servermssqldatadbname _log.ldf’可能有誤!
解決方法:
1.新建一個同名的數(shù)據(jù)庫2.再停掉sqlserver服務(wù)(注意不要分離數(shù)據(jù)庫)
3.用原數(shù)據(jù)庫的數(shù)據(jù)文件覆蓋掉這個新建的數(shù)據(jù)庫4.再重啟sqlserver服務(wù)
5.此時打開企業(yè)管理器時會出現(xiàn)置疑,先不管,執(zhí)行下面的語句(注意修改其中的數(shù)據(jù)庫名)6.完成后一般就可以訪問數(shù)據(jù)庫中的數(shù)據(jù)了。這時,數(shù)據(jù)庫本身一般還有問題,解決辦法是:利用數(shù)據(jù)庫的腳本創(chuàng)建一個新的數(shù)據(jù)庫,然后通過DTS將數(shù)據(jù)導(dǎo)進(jìn)去。
以下是引用片段:
use master
go
sp_configure ’allow updates’,1 reconfigure with override
go
update sysdatabases set status =32768 where name=’置疑的數(shù)據(jù)庫名’
go
sp_dboption ’置疑的數(shù)據(jù)庫名’, ’single user’, ’true’
go
dbcc checkdb(’置疑的數(shù)據(jù)庫名’)
go
update sysdatabases set status =28 where name=’置疑的數(shù)據(jù)庫名’
go
sp_configure ’allow updates’, 0 reconfigure with override
go
sp_dboption ’置疑的數(shù)據(jù)庫名’, ’single user’, ’false’
go
解決方法:
1.新建一個同名的數(shù)據(jù)庫2.再停掉sqlserver服務(wù)(注意不要分離數(shù)據(jù)庫)
3.用原數(shù)據(jù)庫的數(shù)據(jù)文件覆蓋掉這個新建的數(shù)據(jù)庫4.再重啟sqlserver服務(wù)
5.此時打開企業(yè)管理器時會出現(xiàn)置疑,先不管,執(zhí)行下面的語句(注意修改其中的數(shù)據(jù)庫名)6.完成后一般就可以訪問數(shù)據(jù)庫中的數(shù)據(jù)了。這時,數(shù)據(jù)庫本身一般還有問題,解決辦法是:利用數(shù)據(jù)庫的腳本創(chuàng)建一個新的數(shù)據(jù)庫,然后通過DTS將數(shù)據(jù)導(dǎo)進(jìn)去。
以下是引用片段:
use master
go
sp_configure ’allow updates’,1 reconfigure with override
go
update sysdatabases set status =32768 where name=’置疑的數(shù)據(jù)庫名’
go
sp_dboption ’置疑的數(shù)據(jù)庫名’, ’single user’, ’true’
go
dbcc checkdb(’置疑的數(shù)據(jù)庫名’)
go
update sysdatabases set status =28 where name=’置疑的數(shù)據(jù)庫名’
go
sp_configure ’allow updates’, 0 reconfigure with override
go
sp_dboption ’置疑的數(shù)據(jù)庫名’, ’single user’, ’false’
go