从备份 SQL Server Express 创建/恢复数据库
我的计算机上没有 SQL Server Management Studio。
我有一个数据库备份(SQL Server 2008 R2)。我的计算机上安装了与 Visual Studio 2010 Ultimate 一起安装的 SQL Server Express。
如何在数据库上恢复此备份并将其附加到 SQL Server Express?
有没有不使用 SQL Managment Studio Express 的解决方案?
I don't have SQL Server Management Studio on my machine.
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.
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
即使使用 SQL Server Management Studio Express,您也无法恢复此备份。与 Visual Studio 2010 一起安装的 Express 版本是 SQL Server 2008 版本 - 您的备份来自 SQL Server 2008 R2 版本 - 这些备份不能
您需要下载SQL Server 2008 R2 Express 版本,当您使用时 - 获取带有 Management Studio 的版本!安装它,然后您就可以恢复数据库备份。
如果您确实想在不使用 Mgmt Studio 的情况下恢复数据库 - 您当然可以在 T-SQL 中使用
RESTORE
语句,并使用sqlcmd
命令行工具:(当然,还有一个
BACKUP
命令,您可以以类似的方式使用 - MSDN 联机丛书 是您了解语法详细信息的朋友!!)。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.
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.
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 thesqlcmd
command line tool:(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!!).迟到了,但希望对正在观看此内容的其他人有用......
如果问题是在没有 Management Studio 的情况下进行恢复,则可以通过使用 sqlcmd 轻松解决,如 marc_s 已经指出的那样。
但是,如果真正的问题是在不使用 SSMS 的情况下在 SQL 2008 上恢复 2008 R2 备份,那么唯一的解决方案是使用可以读取备份并生成用于创建架构和插入数据的脚本的第三方工具。
想法是在 SQL 2008 上创建空数据库,并使用第三方工具将其与 2008 R2 生成的备份进行比较。
我使用过 ApexSQL Diff 和 ApexSQL Data Diff 在我之前的工作中取得了很好的成功,但 Red Gate(SQL 比较)和 Idera(比较工具集)。如果您在网上查找,您可能会发现更多......
免责声明:我不隶属于上述任何公司......
Late one but hopefully useful to others who are viewing this….
If the problem is restoring without management studio this can be easily solved by using sqlcmd as marc_s already pointed out.
However if the real problem is restoring 2008 R2 backup on SQL 2008 without using SSMS then only solution is using third party tools that can read backup and generate scripts for creating schema and inserting data.
Idea is to create empty database on SQL 2008 and use a third party tool to compare it to backup generated with 2008 R2.
I’ve used ApexSQL Diff and ApexSQL Data Diff with good success in my previous job but there are also good tools from Red Gate (SQL Compare) and Idera (Comparison toolset). If you look up online you’ll probably find a lot more….
Disclaimer: I’m not affiliated with any of the companies mentioned above…
为什么不使用 SQL Managment Studio Express?它是免费的,并且允许您管理本地 sql express 实例。
http://www.microsoft.com /downloads/en/details.aspx?FamilyID=c243a5ae-4bd1-4e3d-94b8-5a0f62bf7796
Why don't you get SQL Managment Studio Express? It is free, and should allow you to administer local sql express instances.
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c243a5ae-4bd1-4e3d-94b8-5a0f62bf7796
以下链接提供了与 marc_s 类似的解决方案,而且更深入。我能够使用下面链接中提供的解决方案成功地从备份文件创建一个新的数据库。
http://codeonaboat.wordpress .com/2012/02/16/sql-server-2008-creating-a-database-from-a-bak-file/
下面的解决方案是从上面的链接复制的:
In SSMS,在数据库服务器的master数据库中打开一个查询窗口。您将在其中运行以下查询。
查看.bak文件中已备份的数据库的“LogicalName”是什么
<块引用>
仅从磁盘恢复文件列表 =
'c:\DatabaseBackups\dev2012021601.bak'
这将为您提供数据库及其关联日志文件的逻辑名称。假设名称为“dbname”和“dbname_log”,
C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA
是 SQL Express 通常保存其数据文件的目录。您可以找到数据库服务器正在使用的目录,方法是从中选择一个数据库,右键单击并打开属性对话框,然后从左侧选择“文件”选项。这应该可行,此时您应该能够访问数据库“dbForSocialMigration”,其中填充了 .bak 文件中的所有表和数据。
Following link provides similar solution as marc_s, and it goes even deeper. I was able to successfully create a new DB from Backup file with the solution provided in the link below.
http://codeonaboat.wordpress.com/2012/02/16/sql-server-2008-creating-a-database-from-a-bak-file/
The solution below is copied from above link:
In SSMS, open a query window in the master database of the database server. That’s where you will run the following queries.
See what the “LogicalName” of the database that has been backed up in the .bak file is
This will give you the logical name of the database and its associated log file. Lets assume that the names are “dbname” and “dbname_log”
C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA
is the directory where SQL Express usually keeps its data files. You can find the directory your database server is using by selecting a database from it, right clicking and opening the properties dialog and selecting the “Files” option from the left.That should work, and at that point you should be able to access the database “dbForSocialMigration” populated with all the tables and data from the .bak file.