读取 SQL Server 2008 中的日志文件 (*.LDF)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9767054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:53:25  来源:igfitidea点击:

Read the log file (*.LDF) in SQL Server 2008

sqlsql-server-2008logfiles

提问by Neuvill

I'm searching for a way to read the SQL Server 2008log file, not to show the information, but to read the meaning of the symbols and the structure of the LOG table. I'm using DBCC LOG('my_table', 3).

我正在寻找一种读取SQL Server 2008日志文件的方法,不是为了显示信息,而是为了读取符号的含义和LOG表的结构。我正在使用DBCC LOG('my_table', 3).

回答by JdMR

First of all, in order to be able to read any meaningful data your database needs to be in full recovery mode. Otherwise you probably won't find much there. There are two ways to do this. Using undocumented SQL functions and using third-party tools.

首先,为了能够读取任何有意义的数据,您的数据库需要处于完全恢复模式。否则你可能不会在那里找到太多东西。有两种方法可以做到这一点。使用未记录的 SQL 函数和第三方工具。

SQL Functions:

SQL 函数:

DBCC LOG and fn_dblog - more details hereand here

DBCC LOG 和 fn_dblog -这里这里有更多细节

Third-party tools:

第三方工具:

Toad for SQL Server(actually does a lot more than reading logs) and ApexSQL Log(focuses only on reading transaction logs).

Toad for SQL Server(实际上不仅仅是读取日志)和ApexSQL Log(仅专注于读取事务日志)。

回答by Ardalan Shahgholi

See my answer in this Stack Overflow post: How can I view SQL Server 2005 Transaction log file

请参阅这篇 Stack Overflow 帖子中的答案:如何查看 SQL Server 2005 事务日志文件

Or

或者

Use this command:

使用这个命令:

Select * from ::fn_dblog(null,null)

And for more information, see How Do You Decode A Simple Entry in the Transaction Log.

有关更多信息,请参阅如何解码事务日志中的简单条目

回答by Andy Irving

From your comments, if you want to see the queries users issue:

根据您的评论,如果您想查看用户发出的查询:

Start a trace or use extended events to capture the sql text. See How to: Create a Trace (SQL Server Profiler).

启动跟踪或使用扩展事件来捕获 sql 文本。请参见如何:创建跟踪(SQL Server Profiler)