打开SQL Server .bak文件(不还原!) [英] Opening a SQL Server .bak file (Not restoring!)

查看:474
本文介绍了打开SQL Server .bak文件(不还原!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读许多Google帖子以及有关如何从.bak文件还原SQL Server中的数据库的StackOverflow问题.

I have been reading a LOT of google posts and StackOverflow questions about how to restore a database in SQL Server from a .bak file.

但是它们都没有说明如何只读取数据库备份中的表. (无论如何我都找不到吗?)

But none of them states how to just READ the tables in the database-backup. (None that I could find anyway?)

我只想检查一些现在已删除的旧信息,而无需实际还原完整的数据库. 这可能吗?

I just want to check out some old information which now has been deleted, without actually restoring the full database. Is this possible?

.

我只是想发布我的T-SQL解决方案,以便其他人可以使用它,所以我可以回头查看它;)

I just wanted to post my T-SQL solution to the problem, so others may use it and I can go back and look it up ;)

首先,我创建了一个名为backup_lookup的新数据库,并将其脱机. 之后,我可以将旧数据库mydb恢复到新数据库,而无需接触原始数据库.

First I created a new database called backup_lookup and took it offline. After this I could restore my old database mydb to the new one, without ever touching my original.

USE master
GO
RESTORE DATABASE backup_lookup
 FROM DISK = 'D:\backup\mydb.bak'
WITH REPLACE,
 MOVE 'mydb' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\backup_lookup.mdf',
 MOVE 'mydb_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\backup_lookup_log.ldf'
GO

我希望这会有所帮助:)

I hope this helps :)

推荐答案

从SQL Server 2008 SSMS(SQL Server Management Studio)中,只需:

From SQL Server 2008 SSMS (SQL Server Management Studio), simply:

  1. 连接到数据库实例(例如,"localhost \ sqlexpress")
  2. 要么:

  1. Connect to your database instance (for example, "localhost\sqlexpress")
  2. Either:

  • a)选择要还原到的数据库;或者,或者
  • b)只需创建一个新的空数据库即可还原到.

右键单击,任务,还原,数据库

Right-click, Tasks, Restore, Database

PS:我再次强调:您可以轻松地在临时数据库"上执行此操作-您不需要需要覆盖当前数据库.但是您要做需要还原.

PS: Again, I emphasize: you can easily do this on a "scratch database" - you do not need to overwrite your current database. But you do need to RESTORE.

PPS:如果希望编写脚本,还可以使用T-SQL命令完成同样的事情.

PPS: You can also accomplish the same thing with T-SQL commands, if you wished to script it.

这篇关于打开SQL Server .bak文件(不还原!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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