如何添加.mdf文件到数据库? [英] How to add .mdf file into database ?

查看:208
本文介绍了如何添加.mdf文件到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

我只下载了一个.mdf文件.请帮助我如何将其添加到Sql Server数据库中?


问候
sashi

Dear Sir,

I have dowloaded only a .mdf file.Kindly help me how can i add it into the Sql Server database ?


regards
sashi

推荐答案

但是,在没有日志文件的情况下附加到mdf文件后,您将没有事务日志,请考虑以下解决方案:
在SSMS中运行此查询
However you will not have the transaction log after attaching to a mdf file without its log file, consider this solution :
Run this query in SSMS
EXEC sp_attach_single_file_db @dbname='DBName', @physname=N'c:\data\db_data.mdf'


然后刷新数据库"部分,您将看到它.


欲了解更多信息,请点击这里:
http://blog.sqlauthority .com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/ [


And then refresh you Database section an you will see it.


For more information read here :
http://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/[^]


Hope it helps.


将文件粘贴到mssqlserver的数据文件夹中.

paste your file inside data folder in mssqlserver.

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data



然后打开sqlserver.在对象资源管理器中,右键单击数据库,然后选择附加.

浏览,选择要附加的数据库,然后单击附加.



then open sqlserver. In the object explorer RightClick on database and select attach.

browse , select the database to attach and click attach. this will do the trick for you.


,如果您使用的是SQL Server Express Edition,还可以通过连接字符串将mdf附加到SQL Server实例,请参见: http://www.connectionstrings.com/sql-server-2008 [
And if you''re using SQL Server Express Edition you can also attach the mdf to the SQL Server instance by connection string, see: http://www.connectionstrings.com/sql-server-2008[^] and example Attach a database file on connect to a local SQL Server Express instance


这篇关于如何添加.mdf文件到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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