How to read the meta data out of SQL Server backup files directly?

风格不统一 提交于 2019-12-10 13:02:22

问题


Generally to get the meta data from SQL Server backup files, we need to use TSQL commands like restore headeronly or restore filelistonly. However, there are some third party tools can read this information directly from the backup files, like this one http://www.yohz.com/sqlbakreader_details.htm. Since this tool don't have a command line version, which makes it less useful. I want to know whether there are some ways that I can read this data directly.

Thanks.


回答1:


The .bak file is a Microsoft Tape Format file. Here's a PDF that contains the format.

Of interest to you will be:

For a quick dump (if you are on the SQL Server in question that created the backup), you can do select from the [msdb].[dbo].[backup*] tables.

See this article for more info.




回答2:


I think you may be able to use SQL Servers SMO libraries and write your own in .net or Powershell. If you take a look at this page http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.readbackupheader.aspx there are code samples in VB.Net and Powershell.



来源:https://stackoverflow.com/questions/17793006/how-to-read-the-meta-data-out-of-sql-server-backup-files-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!