dbTalk Databases Forums  

SQL Server Profiler and Prepared Queries

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss SQL Server Profiler and Prepared Queries in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mark Price
 
Posts: n/a

Default SQL Server Profiler and Prepared Queries - 04-30-2009 , 11:49 AM






I am trying to figure out how to detect issues with queries via SQL Server
Profiler and trace files. Because of the way we utilize JDBC with our
application, most of our queries appear in the trace files as prepared
statements. My understanding is that when the statement is “prepared” it is
assigned a handle. And the later this handle is used in sp_execute statement.
If I am incorrect please let me know.

My question is, how do tie the sp_execute statement back to the prepared
query, and how would you determine if the query is taking a long to time to
execute?

Thanks,
Mark


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: SQL Server Profiler and Prepared Queries - 04-30-2009 , 05:01 PM






Mark Price (MarkPrice (AT) discussions (DOT) microsoft.com) writes:
Quote:
I am trying to figure out how to detect issues with queries via SQL
Server Profiler and trace files. Because of the way we utilize JDBC
with our application, most of our queries appear in the trace files as
prepared statements. My understanding is that when the statement is
prepared it is assigned a handle. And the later this handle is used in
sp_execute statement.
If I am incorrect please let me know.
Your description seems familiar to me.

Quote:
My question is, how do tie the sp_execute statement back to the prepared
query, and how would you determine if the query is taking a long to time
to execute?
The only technique I've used is to backtrack in the trace, but if the
statement was prepared before the trace started, that is not going to
help.

I searched around the DMV:s to see if there was anyplace where you could
look up a spid and handle to get the query text, but now.

However, you can add the column sql_handle to the trace. Then you can
use this handle to look up the query text with sys.dm_exec_sql_text.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.