在服务器2008 R2中附加没有ldf的mdf文件 [英] Attach mdf file without ldf in server 2008 R2

查看:201
本文介绍了在服务器2008 R2中附加没有ldf的mdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hI,

我有AdventureWorks2008R2_Data.mdf文件.并且我想将其附加到可能的Sql Server 2008R2数据库中.我没有ldf文件.我运行以下脚本..

hI,

I have AdventureWorks2008R2_Data.mdf file. and I want to attach it to may Sql Server 2008R2 database. I don''t have its ldf file though. I run the following script..

USE [master]
CREATE DATABASE Adventure ON
(FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\AdventureWorks2008R2_Data.mdf')
FOR ATTACH_REBUILD_LOG
GO 



它给我以下错误消息...



It gives me following message with an error...

Msg 5120, Level 16, State 101, Line 2
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\TestDb_log.LDF". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\TestDb_log.LDF" may be incorrect.
New log file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\Adventure_log.LDF' was created.



如何摆脱这种情况?



How to get rid of this???

推荐答案

为什么不从获取新副本Microsoft SQL Server社区项目和样本 [^ ]

无论如何,该错误有点令人困惑.您尝试附加主文件AdventureWorks2008R2_Data.mdf,但错误消息表明SQL Server无法找到文件TestDb_log.LDF.这似乎不是AdventureWorks数据库的默认日志文件.您是否真的要附加一个已被Sql Server使用的mdf文件?
Why not get a fresh copy from Microsoft SQL Server Community Projects & Samples[^]

Anyhow the error is a bit confusing. You try to attach primary file AdventureWorks2008R2_Data.mdf but the error message implies that SQL Server cannot find file TestDb_log.LDF. That doesn''t seem the be the default log file of the AdventureWorks database. Are you actually trying to attach a mdf file that is already in use by Sql Server?


这篇关于在服务器2008 R2中附加没有ldf的mdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆