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

3

6

I'm searching for a way to read the SQL Server 2008 log 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).

Printable answered 19/3, 2012 at 8:35 Comment(9)
You cannot directly read the SQL Server transaction log file - that's not really documented. Why do you need to read the log file, what do you expect to find in there??Chiou
just to know the users logs and the instructions that they made...Printable
use this command DBCC LOG('my_table', 3) in sql server management studio and you'll see a table that contents logs, if you read it you'll see in a column called [comment] a list of operation made like update insert, and you'll see the date of the operation and many other informations.Printable
Yes - but that information is not in the transaction logs in any textual form or anything. DBCC collects and interprets the raw data - you'll have to have the source code for DBCC to understand how to do this (and you can't have that - it's not an open source project, after all)Chiou
that's wired, so how we use of the log file? i'm workin in local database and im the administrator and i can't see what hapends in the log file? because im gona make this DB in online, and i have to see what the users do... is there another way to do that?Printable
You don't use the transaction log yourself - it's a SQL Server internal thing, really. Don't try to tamper with it, don't try to read it out - just let SQL Server do its work!Chiou
okey... so what you suggest to have a back up of the logs and transaction? a transact table i think... that records all the transaction...Printable
You need to learn about the transaction log and its purpose and use: Managing Transaction Logs, Introduction to the SQL Server transaction log, Purpose of the SQL Server Transaction logChiou
The way of reading a log file in SQL Server by using fn_dblog() function is too long. Instead of this you can try Free SQL LDF ViewerInvolucre
C
9

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

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.

Cupellation answered 29/9, 2013 at 18:49 Comment(0)
S
11

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 Functions:

DBCC LOG and fn_dblog - more details here and here

Third-party tools:

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

Sleet answered 18/2, 2013 at 22:31 Comment(0)
C
9

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

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.

Cupellation answered 29/9, 2013 at 18:49 Comment(0)
I
3

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).

Indevout answered 2/4, 2012 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.