Home All Groups Group Topic Archive Search About

Mapping sql statements to TransactionId in a profiler trace file

Author
28 Sep 2007 2:24 PM
Paulo Eduardo Neves
Hi,

I've added the TransactionId column to the tracer file in SQL
Profiler, but the column just have data when a transaction is starting
or finishing.

How do I map a TransactionId  to a SQL statement? Is it something
possible to do?

My objective is to generate a performance report from a trace file. It
would
answer questions like "Which are the tables involved in the longest
running transactions?" or "Which tables are involved in the rolled
back
transactions?".


I'm using SQL Server 2000.

kind regards,
Paulo Eduardo Neves

Author
28 Sep 2007 3:30 PM
Ed Murphy
Paulo Eduardo Neves wrote:

> I've added the TransactionId column to the tracer file in SQL
> Profiler, but the column just have data when a transaction is starting
> or finishing.
>
> How do I map a TransactionId  to a SQL statement? Is it something
> possible to do?

Determine which column(s) produce a sort order equal to the order
in which events were written to the trace table, then simply query
which rows come between the start or end of a transaction when
sorting on those columns.

To determine which transactions are the longest, which were rolled
back, etc., do something like

   select t1.event_time, t2.event_time, t2.commit_or_rollback
   from the_table t1
     join the_table t2 on t1.TransactionID = t2.TransactionID
                      and t1.event_type = 'Start Transaction'
                      and t2.event_type = 'End Transaction'

(Actual column names and values are probably different; I'm just
trying to illustrate concepts here.)
Author
28 Sep 2007 7:42 PM
Paulo Eduardo Neves
On 28 set, 12:30, Ed Murphy <emurph***@socal.rr.com> wrote:
> Paulo Eduardo Neves wrote:
> > I've added the TransactionId column to the tracer file in SQL
> > Profiler, but the column just have data when a transaction is starting
> > or finishing.
>
> > How do I map a TransactionId  to a SQL statement? Is it something
> > possible to do?
>
> Determine which column(s) produce a sort order equal to the order
> in which events were written to the trace table, then simply query
> which rows come between the start or end of a transaction when
> sorting on those columns.

I don't think it will work, since I have transactions running
concurrently in the trace file. But I think I can do it in queries
with the same SPID. Would this approach include in the transaction the
executed triggers?

regards,
Paulo

AddThis Social Bookmark Button