How to use the profiler to know what query is accessing a databse

  • Hello ,

    I have an application that reads data from a database, How can i use the profiler to pull the script that is reading and pulling data by the application.

    Thanks

    I learn from the footprints of giants......

  • Since you're on SQL Server 2012, instead of using Profiler, I'd strongly recommend you use Extended Events. They have a much more lightweight footprint than Trace Events (you wouldn't want to use Profiler directly anyway) and they filter in a much more superior manner. To track the queries called, I'd suggest capturing both sql_batch_complete and rpc_complete. I don't know your connection settings, so I'm not sure if you pass the application name or use a specific login, or what? But one of these things will allow you to filter to only capture the events from the application. The best way to output the capture is to a file. You can read the file live, or query against it later using the SSMS GUI. You can even load the data later into a table for querying.

    For an introduction to extended events, read here.

    "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

  • Hi

    Consider using the Who is Active v11.11 script from Adam Machanic. It has helped me a lot in the past.

  • Terence Keys (1/6/2017)


    Hi

    Consider using the Who is Active v11.11 script from Adam Machanic. It has helped me a lot in the past.

    This is especially helpful if the query is already running and you want to know what it is, profiler or extended events would have to be started before the query to capture it, they don't signal any event during execution of a long running query.

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

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