|
Posted by Erland Sommarskog on 10/02/92 11:49
birju (floating.buddha@gmail.com) writes:
> The statement is prepared before I start the profiler and the client
> keeps that connection - so I can't see its preparation without
> restarting the server (it's a web application).
Aha. Thanks for the clarification.
It occurred to me one thing that you could try, although I'm not sure
that it works with prepared statements, and that is the function fn_get_sql
that was introduced in SQL 2000 SP3.
From sysprocesses you get a handle, and two statement offsets, start
and end. You feed the handle to fn_get_sql, and get back a table with
object id for the current stored procedure (if applicable), and the text
of the current scope. Then you use the offsets to get the exact statement.
I have it all packaged in a stored procedure aba_lockinfo, that you can
download from http://www.sommarskog.se/sqlutil/aba_lockinfo.html. You
cannot correlate directly with Profiler, but long-running statements are
more likely to turn up in the snapshot it produces.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|