SQL Server:从.mdf导入数据库? [英] SQL Server: Importing database from .mdf?
本文介绍了SQL Server:从.mdf导入数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的本地机器上有一个.mdf文件。
I have an .mdf file on my local box.
我的本地机器上安装了SQL Server 2008 Express和SQL Management Studio 2008 Express。
I have SQL Server 2008 Express and SQL Management Studio 2008 Express installed on my local box.
在世界上如何将这个.mdf文件作为新数据库导入到我的SQL Server中?
How in the world do I import this .mdf file as a new database into my SQL Server?
这项荒谬的普通任务每天必须在全球范围内执行数千次,而我却无法在Management Studio Express中弄清楚该怎么做。
This seems like a ridiculously common task that must be performed thousands of times a day across the globe, and I cannot figure out how to do it in Management Studio Express.
我缺少什么?
推荐答案
请参阅:如何:将数据库文件附加到SQL Server Express
通过sqlcmd登录数据库:
Login to the database via sqlcmd:
sqlcmd -S Server\Instance
然后发出命令:
USE [master]
GO
CREATE DATABASE [database_name] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\<database name>.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\<database name>.ldf' )
FOR ATTACH ;
GO
这篇关于SQL Server:从.mdf导入数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文