Question:Can you trace a query (just a query text)

  • I just got this support request,simple: @sqlteam can their be a trace set on following query since its running slow on our end,while it runs very fast on the server itself.

    Followed by 35 lines of sql code & I'm still trying to figure out what tables it uses, I analysed it & see no big issues.

    So I was wondering can you put a trace on the executing of queries that contain certain text.

  • I think you want to Edit the TextData column in profiler and set a filter on the text using the 'like' field

    Right-click on the TextData column in profiler (Events Selection) and choose 'Edit Column Filter'. I suggest you experiment with the filter on a dev box in case you grind the server to a halt.

    Hope that helps.

  • You can use a statement level trace event, but, be very cautious because those generate a ton of data and might have a negative impact on performance, even if you filter the statements so you're only capturing for one query.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply