Getting the SQL from a sp_execute statement in Microsoft SQL Profiler

While using Microsoft’s SQL Profiler to tune an application I noticed the developers have been using prepared SQL, so all I see is sp_execute and the parameters being passed. But I wanted to see the SQL that is being passed. The first pass through google provided some SQL that could be run against the management tables but I didn’t have permission to do that..

Luckily a colleague told me all I had to do was enable capturing the SP:CacheHit event and this event fires right before the sp_execute and has the text of the query in it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s