Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can I read the transaction log?

Posted on 2003-11-18
10
Medium Priority
?
537 Views
Last Modified: 2008-03-10
I want to know what changes makes a program to a database.
I don't know what tables may be affected, or if it's updating, deleting or inserting records in one or more tables.
So I can do 2 things:
Compare the whole database "before" and "now"
Read the transactions that where inserted in the transaction log

I think the second solution might be easier, because the database is quite big...

So, how can I do it (step by step)?
0
Comment
Question by:Chofo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 34

Accepted Solution

by:
arbert earned 2000 total points
ID: 9774580
Nope, you really can't read the transaction log in a meaningful manner.  HOWEVER, there are a couple of third party products that will read the log for you.  LogExplorer http://www.lumigent.com   and NetIQ also has a product http://www.netiq.com.

If you really need to capture "audit track" type information, you'll almost have to add triggers to the table and insert the before and after changes into another table.

Brett
0
 

Author Comment

by:Chofo
ID: 9779409
Brett: thank you for your answer, it's good to know which are all the different approaches to the subject

I've just downloaded a free trial, and I'm also developing some triggers to find out which tables change...
but I don't know how to learn what changed in the table without having to compare the whole table "before" and "after".
For instance, if the "delete" triggers, how do I know which record was deleted?
Is there a shortcut?
0
 
LVL 34

Expert Comment

by:arbert
ID: 9779868
Basically, if you have good primary keys on your table, you will know what record was updated, deleted, or inserted.


Here are a couple of useful links on auditing:

http://www.sql-server-performance.com/auto_audit_2_spotlight.asp
http://www.nigelrivett.net/AuditTrailTrigger.html


Brett
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:Chofo
ID: 9781598
Brett:
I don't quite agree with your statement about primary keys, updates will tend to be next to the bottom, but that's not necessary...

Thanks for the links...

Chofo
0
 
LVL 34

Expert Comment

by:arbert
ID: 9782261
"next to the bottom"  what do you mean?  If the table has a primary key on it, you know EXACTLY what record was affected by an operation..........
0
 

Author Comment

by:Chofo
ID: 9782588
But... how do you know the ID of the record updated?
I can get if it was an update, delete or insert;  but how do I know the ID of the primary key?
0
 
LVL 34

Expert Comment

by:arbert
ID: 9782816
What do you mean the "ID of the primary key"?  If you know the primary key, that is the exact key that is needed to find a record in the database.....
0
 

Author Comment

by:Chofo
ID: 9783123
OK, ID, primary key, it's the same to me.   How do you know which was the record affected by the table update, delete or insert?   Is it there an SQL variable containing the primary key of the last record updated, deleted or inserted?  What's its name?   How do I get the value?
Or else, can I get the "SQL string" executed over the table?
0
 
LVL 34

Expert Comment

by:arbert
ID: 9783251
Nope, you have to know the primary key.  If you're coding the trigger or stored proc, I would hope that you know what it is.

As far as getting the SQL string that executed, the only way to do that (right now anyway) is with profiler.  When you try and get the sql from within a trigger (fn_get_sql) it returns the actual code of the trigger (thanks microsoft)....
0
 

Author Comment

by:Chofo
ID: 9783580
OK, thank you very much!
You've been really helpful...

Chofo
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question