如何恢复和修复MS SQLSERVER数据库的MDF文件

如何恢复和修复MS SQLSERVER数据库的MDF文件,第1张

数据库"置疑"了应该是文件损坏了,例如你把数据库分离后,用记事本打开他会看到很多乱码,强行改动里边的那些乱码,保存后附加数据库,由于里边格式乱了,数据库就"置疑"了。

你首先要进入“单用户模式”,让你可以重新 *** 作数据库,然后用SELECT 命令可以看出什么表出错了(上帝保佑你只是某个表出错了),如果只是某个表出错,而又只是数据错误,不是结构错误,还可以通过运行带WHERE子句的SQL看看数据是到哪里出错,把,错误点以后的数据都删除掉,那至少数据库还可以用。

如果你的数据不是真的都那么要紧的话,用还原功能是最方便可行的办法。当然备份档之后的数据是没有了。

1停止SQL Server的服务,备份SQL Server安装目录下的\data子目录

下故障数据库的两个文件,一个数据文件hbposv6_branch_datamdf,

一个hbposv6_branch_logldf(也有可能非此命名),同时查看磁盘

空间是否有足够的空间;

2启动SQL Server服务(如已停止),创建一个新的数据库,命名为

原来数据库的名字。

3停止SQL Server

4把老数据库的MDF文件(hbposv6_branch_datamdf)替换

新数据库的相应的MDF文件,

并把LDF文件(hbposv6_branch_logldg)删除。

5重新启动SQL Server服务,然后运行如下命令:

Use Master

go

sp_configure 'allow updates', 1

reconfigure with override

go

begin tran

update sysdatabases set status = 32768 where name = 'hbposv6_branch'

--Verify one row is updated before committing

commit tran

go

6停止SQL然后重新启动SQL Server服务,然后运行如下命令

(更换日志文件路径地址):

use master

go

DBCC TRACEON(3604)

DBCC REBUILD_LOG

('hbposv6_branch',

'c:\Program Files\Microsoft SQL Server\MSSQL\Data\hbposv6_branch_logldf')

--在这里,请输入你的数据库的路径

go

7停止SQL然后重新启动SQL Server服务,然后运行:

use master

go

update sysdatabases set status = 8 where name = 'hbposv6_branch'

go

sp_configure 'allow updates', 0

reconfigure with override

go

8运行dbcc checkdb(db_name) 检查数据库的完整性

9修复数库

--请在查询分析器中执行下列语句执行前断开其它

所有数据库连接,最好是断开网线

--如果不是该数据库名,请将数据库

--hbposv6_branch

--改为要修复的数据库

USE master

Go

--单用户模式

EXEC sp_dboption 'hbposv6_branch', 'single user', 'TRUE'

go

--数据库检查

DBCC CHECKDB ('hbposv6_branch')

Go

--如果返回结果出现了红色的提示文字,说明数据库中存在错误,需要修复

--数据库修复

DBCC CHECKDB ('hbposv6_branch','repair_rebuild')

Go

--再次数据库检查,如果返回结果中没有了红色的提示文字,

说明修复成功;

DBCC CHECKDB ('hbposv6_branch')

Go

--否则意味着还需要更高级别的修复;尝试将上面修复语句的

'repair_rebuild'换为'repair_allow_data_loss'再试,

之后再次检查数据库。

--如果还有错误未修复,请把这些信息以文字的方式发给我们

--退出前请一定要执行以下语句返回到多用户模式

EXEC sp_dboption 'hbposv6_branch', 'single user','FALSE'

go

注:都要把 dbname 替换成真实的数据库名字。

An unforgettable things but the ups and downs of the relationship between the gas undertakings every worker's survival and fate, oneself in the post has worked eighteen years, honor, hard-working, share

Sweats are so saturated with for gas undertakings of contribution and joy!

One of the first things that unforgettable It is the summer of 2001, the unit organized a free travel to reward for so many years of hard work to me The us

The income of a family is a joy When I hear the authority of the meeting again in the name of traveling, heart envy

In face with jealousy can reveal to hear the news, so I'm happy days didn't sleep well Fly to yunnan, many good fortune!

For the first time the plane is excited and nervous overlap, when the clouds from outside the window, through the earth beneath shuttle in the far, exclamation of human civilization

Big Time past, unconsciously in yunnan has arrived Everything is so beautiful scenery lets a person mosey, relaxed!

July 13th, a history of the day, Beijing becomes the host city for the 2008 Olympics, nationalistic celebration, and is so beautiful day for me

The body of the passengers in yunnan nightmare memories It is a sunny summer, we ended up in Dali, a visit to the lijiang, travel

Cars speeding in the rugged mountain path, suddenly the pouring rain, yunnan weather like three-year-old baby as fickle, vagaries But we did not take this as a

All very happy matter, carriage, kunming, Dali, a stone of the three towers, features, erhai lake And the upcoming lijiang naxi ancient LongXueShan margin,!

Around noon, when the cab drove a detour after, I suddenly felt dizzy, flip, followed by a loud noise, when their consciousness is two words: finished!

Then is dark, unconscious When I awake when the car has a moment of silence as wolves, and then is burst tore heart crack lung cries, I detection

Check your body circumstance that is not serious, the first thing is to find my camera and then record the unforgettable moments, but also help you clean

Baggage, emergency evacuation for export, because the car is not very clear, any possible new unpredictable situation, then, a colleague chuai broken car most

The Windows, everybody busy behind from the window of the orderly, when I climbed out of the car body, and after that have turned over 180 'side in the roadside ditch, only a few meters away from the cliff

Two trees, is saved all life, a broken in body, lazio next, feel the heart and clinking miss distant relatives, but can't call peace,

Because everyone knows it will give family more psychological burden Although very roads, but can't think too much, all the rescue injured colleague, the most important is to call in the rain

One of the curtain down injured quake-damaged section is the most serious WangXingTian colleagues, his waist, like two colleagues fractures with other colleagues with help from a seaman

I also recorded serbain unlucky side side, I heard was to cry, the female colleague of male colleagues ManMaSheng inclusion in together, let people be agitated, anxiety, then

While photography per side with a stable comfort to a colleague, is the place where the accident happened SheShen returns while waiting for rescue workers to photography For mountain road, about three slip

Hours later, rescue workers and local government officials had arrived on the scene comforted, visiting!

The manager of our trip to HeYuZhen notch from accident has been uninterrupted time with the situation around, contact with all the other old, and actively and local leaders

To do a detailed report, in the evening, we handle the good scene, and hurried county hospital, to visit our seriously injured several colleagues, properly arrange, temporary opened an emergency meeting,

Verification for everybody, decided to continue to their destination

After left colleagues have exhausted the instigation of leadership, in, temporarily forget what happened today, sit on the quake-damaged section of the passenger, temporary attune on night, smooth

Reached our destination, lijiang! Originally arranged tourism projects are now being stranded, one is all have no energy to organize activities, 2 it is to take care of the wounded, how can you colleagues

From the left of the mood complete journey! So the travel only after the mood has come, typically alls gone, hurry The rest of the time HeYuZhen manager

Always on the phone and travel to discuss issues In Beijing with the leadership, travel agency also came to the airport, and the decision of sympathy to our secured this journey of yunnan

Give each compensation But in later days, we have suffered these co-workers were just compensation at the rehabilitation and organization of the matters are power units

One person to suppress down Many ask no final answer ~!

Because of the organizer and travel agencies are friends, so these feelings of unit colleague is still can exist Chinese modern social interpersonal relationship is so We can, in the eaves of strong rise! The fate of the people will only so We dare not anger, not in word about today It is not only the people in society, also the society nowadays implicative nowadays

以上就是关于如何恢复和修复MS SQLSERVER数据库的MDF文件全部的内容,包括:如何恢复和修复MS SQLSERVER数据库的MDF文件、怎样修复已经损坏的SQL数据库、我用的速达3000单机版,电脑更换了主板没重做系统,速达软件损坏无法进入,所以就无法在软件里做出备份,等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10122836.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存