简体   繁体   English

sql server 2005 .mdf .ldf文件

[英]sql server 2005 .mdf .ldf files

我有这两个文件(.MDF和.LDF)如何将它们附加到microsoft sql server以查看其内容?

In Management Studio, in Object Explorer, right-click on the Databases folder. 在Management Studio的“对象资源管理器”中,右键单击“数据库”文件夹。

Choose Attach... 选择附加...

At the top of the section titled "Databases to attach", click the Add button. 在标题为“要附加的数据库”部分的顶部,单击“添加”按钮。

In the displayed folders and files, navigate to your .mdf file and click on it. 在显示的文件夹和文件中,导航到.mdf文件并单击它。

Click OK. 单击确定。

That's all you have to do. 这就是你要做的一切。

Execute this command from SQL command line (such as query analyzer). 从SQL命令行(例如查询分析器)执行此命令。 Replace AdventureWorks with the name you got. 用您拥有的名称替换AdventureWorks。

EXEC sp_attach_db @dbname = N'AdventureWorks', @filename1 = N'C:\AdventureWorks_Data.mdf', 
  @filename2 = N'C:\AdventureWorks_log.ldf';

If you don't have query analyzer handy run this from windows command prompt: 如果你没有查询分析器方便运行从Windows命令提示符:

 osql -E -S.\sqlexpress -Q"EXEC sp_attach_db @dbname = N'AdventureWorks', @filename1 = N'C:\AdventureWorks_Data.mdf', @filename2 = N'C:\AdventureWorks_log.ldf'"

Install if you have not do it yet, the sql engine, then using the sql management studio you can use the "Attach" utility to create a database with your files. 如果你还没有安装sql引擎,然后使用sql management studio,你可以使用“Attach”实用程序来创建一个包含你文件的数据库。 The attach menu is in the submenu right-click in the server node. 附加菜单位于子菜单中,右键单击服务器节点。

Those files represent an existing SQL Server DB, so are irrelevant if you want to create a new one. 这些文件代表现有的SQL Server数据库,因此如果要创建新文件则无关紧要。

If you want to work with them or create a new DB, places to start would be with a download of either SQL Server 2008 Express or SQL Server 2005 Express , both free. 如果您想使用它们或创建一个新的数据库,那么要开始的地方是免费下载SQL Server 2008 ExpressSQL Server 2005 Express

EDIT : Since you already have SQL Server, DOK's answer is best. 编辑:由于你已经有SQL Server,DOK的答案是最好的。

Whoever gave you those two files is doing it wrong. 谁给你这两个文件是错误的。 It is a much better practice to create a backup of a database and restore the backup to a new or existing server/instance/database. 创建数据库备份并将备份还原到新的或现有的服务器/实例/数据库是一种更好的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM