Can I read the transaction log?

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)?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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   and NetIQ also has a product

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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChofoAuthor Commented:
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?
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:

Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

ChofoAuthor Commented:
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...

"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..........
ChofoAuthor Commented:
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?
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.....
ChofoAuthor Commented:
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?
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)....
ChofoAuthor Commented:
OK, thank you very much!
You've been really helpful...

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.