惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 花光月影

PowerDesign的使用技巧 [转贴]SQL Server用户连接的管理 [转]程序设计中的感悟 几个开源的PORTAL sql2000中修改表的所有者的存储过程 [转]如何让你的SQL运行快起来,希望有所帮助 影响SQLSERVER的性能的一些指标 久不见矣 程序中无法获得Request.ServerVariables("HTTP_REFERER")的值,寻求解决方法~~~~ 农历年底大家都很忙吗? 数据库的安全策略 SQL 事件探查器术语 SQL2000滴系统存储过程--sp_changeobjectowner(更改当前数据库中对象的所有者) SQL学习笔记----SQL2000中的角色及功能 .net中,如何获得活动目录(AD)上的密码失效时间? SQL数据库的事务日志意外增大或充满的处理方法 Sql Server数据库的备份和恢复措施 ASP调用.net的webservices的实现方法 ASP调用WebServices的方法?
【转】如何通过mdf文件还原数据库的两种方法
花光月影 · 2009-08-25 · via 博客园 - 花光月影

 方法一(日志文件完好)
1.新建同名数据库。
2.把该数据库设置为脱机。
3.删除其日志文件(.LDF),不删除后边的过程执行通不过。
4.在查询分析器中以超级用户登入,执行以下存储过程,必须以超级用户登入,这是系统级存储过程。
EXEC sp_detach_db @dbname = 'xxx'    //@dbnam为要还原的数据库
EXEC sp_attach_single_file_db @dbname = 'xxx', @physname = 'yyyy'   //@physname为.mdf文件路径
5.把该数据库设置为联机。
6.刷新数据库,表出来了,数据完好

方法二(无日志文件或日志文件损坏)
    1.新建一个同名的数据库

  2.再停掉sql server(注意不要分离数据库)

  3.用原数据库的数据文件覆盖掉这个新建的数据库

  4.再重启sql server

      5.此时打开企业管理器时会出现置疑,先不管,执行下面的语句(注意修改其中的数据库名)

                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

  6.完成后一般就可以访问数据库中的数据了,这时,数据库本身一般还要问题,解决办法是,利用

  数据库的脚本创建一个新的数据库,并将数据导进去就行了.