• Dave Ballantyne (9/16/2010)


    What Gail showed will work if the "Begin Tran" statement is within the presently executing batch.

    What it will show is the last batch executed by a session that still has an open transaction at the time the query is run. So if you run the following on one connection:

    Batch 1: Begin transaction

    Batch 2: Insert ...

    Batch 3: Delete ...

    and then from another connection run that query, it'll show the Delete statement as that's the last batch that the connection with the open transaction ran.

    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