Viewing specific query from transaction log

  • Hi everyone -

    I'm trying to debug a problem that occurred in our application that involved a query that ran causing some unexpected updates.

    The event occurred about a week ago. We create full backups (.bak) daily along with hourly backups of transactions (.trn).

    My idea was to do a RESTORE to a temp db of the *.bak and *.trn up until the hour the event occurred and then somehow view all updates or inserts in the next *.trn file somehow.

    Is there a way to do this? Is there any way to see that? Any suggestions would be really appreciated!

  • joe 92217 (8/9/2016)


    Hi everyone -

    I'm trying to debug a problem that occurred in our application that involved a query that ran causing some unexpected updates.

    The event occurred about a week ago. We create full backups (.bak) daily along with hourly backups of transactions (.trn).

    My idea was to do a RESTORE to a temp db of the *.bak and *.trn up until the hour the event occurred and then somehow view all updates or inserts in the next *.trn file somehow.

    Is there a way to do this? Is there any way to see that? Any suggestions would be really appreciated!

    Transaction Logs capture the physical operations that occur in the database files (e.g. updating of data on a page/record) as a result of the executed queries, but not the original query text itself.

    You could isolate the exact point in time when your data changed but unless you had a Trace or Extended Events session or some other query monitoring tool running at that time to correlate those changes back to you will not be able to know the original query text.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • joe 92217 (8/9/2016)


    My idea was to do a RESTORE to a temp db of the *.bak and *.trn up until the hour the event occurred and then somehow view all updates or inserts in the next *.trn file somehow.

    A restored DB's transaction log will be empty. The restore process for a log backup replays the results against the DBG, it doesn't write them to the DB's transaction log in the process.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply