从备份 SQL Server Express 创建/恢复数据库 [英] Create/restore database from backup SQL Server Express

查看:43
本文介绍了从备份 SQL Server Express 创建/恢复数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的机器上没有 SQL Server Management Studio.

I don't have SQL Server Management Studio on my machine.

我有一个数据库备份(SQL Server 2008 R2).我的机器上安装了与 Visual Studio 2010 Ultimate 一起安装的 SQL Server Express.

I have a database backup (SQL Server 2008 R2). There is SQL Server Express that installed with Visual studio 2010 ultimate installed on my machine.

如何在数据库上还原此备份并将其附加到 SQL Server Express?
有没有不使用 SQL Managment Studio Express 的解决方案?

How can I restore this back up on a database and attaching it to SQL Server Express?
Is there any solution wihout using SQL Managment Studio Express ?

推荐答案

即使使用 SQL Server Management Studio Express,您也无法恢复此备份.与 Visual Studio 2010 一起安装的 Express 版本是 SQL Server 2008 版 - 您的备份是 SQL Server 2008 R2 版本的备份 - 这些备份不能strong> 恢复到 2008 版本.

Even with SQL Server Management Studio Express, you won't be able to restore this backup. The Express edition being installed with Visual Studio 2010 is version 2008 of SQL Server - your backup is one from a SQL Server 2008 R2 release - those backups cannot be restore onto a 2008 version.

您需要下载 SQL Server 2008 R2 Express版本,当您使用它时 - 使用 Management Studio 获取版本!安装这个,然后你就可以恢复你的数据库备份了.

You will need to download the SQL Server 2008 R2 Express version, and while you're at it - get the version with the Management Studio! Install this, and then you'll be able to restore your database backup.

如果您真的想在不使用 Mgmt Studio 的情况下恢复数据库 - 您当然可以在 T-SQL 中使用 RESTORE 语句并使用 sqlcmd 命令行工具:

If you really really want to restore your database without using Mgmt Studio - you can of course use a RESTORE statement in T-SQL and run this using the sqlcmd command line tool:

RESTORE DATABASE YourDatabaseName
FROM DISK = N'(path to your BAK file)'
WITH FILE = 1,  
MOVE N'(your DB name)' TO N'(your SQL path)database.MDF',  
MOVE N'(your DB name)_LOG' TO N'(your SQL path)database_LOG.LDF',  
NOUNLOAD,  
REPLACE,  
STATS = 10
GO

(当然,还有一个 BACKUP命令,您可以以类似的方式使用 - MSDN 联机丛书 是您了解有关语法的详细信息的朋友!!)

(and of course, there's also a BACKUP command which you can use in a similar fashion - the MSDN Books Online are your friend for details about the syntax!!).

这篇关于从备份 SQL Server Express 创建/恢复数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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