且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从备份 SQL Server Express 创建/恢复数据库

更新时间:2022-11-03 08:14:01

即使使用 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!!).