How to profile SQL Server queries in DataGrip, Rider or IntelliJ with Extended Events
Updated
Why Extended Events
Microsoft has deprecated SQL Trace and SQL Server Profiler for the database engine. Extended Events is the replacement: lighter on the server and able to capture the same things, including every completed batch and remote procedure call your application sends.
By hand in T-SQL
Create a session that captures completed RPC calls and batches, with the SQL text, database and application name:
CREATE EVENT SESSION [capture_queries] ON SERVER
ADD EVENT sqlserver.rpc_completed (
ACTION (sqlserver.sql_text, sqlserver.database_name, sqlserver.client_app_name)),
ADD EVENT sqlserver.sql_batch_completed (
ACTION (sqlserver.sql_text, sqlserver.database_name, sqlserver.client_app_name))
ADD TARGET package0.ring_buffer;
ALTER EVENT SESSION [capture_queries] ON SERVER STATE = START;Read what it captured as XML:
SELECT CAST(t.target_data AS xml) AS captured
FROM sys.dm_xe_session_targets AS t
JOIN sys.dm_xe_sessions AS s ON s.address = t.event_session_address
WHERE s.name = 'capture_queries';And clean up when you are done, so the session doesn't keep running on the server:
ALTER EVENT SESSION [capture_queries] ON SERVER STATE = STOP;
DROP EVENT SESSION [capture_queries] ON SERVER;Creating a session needs the ALTER ANY EVENT SESSION permission on the server. Add predicates such as a minimum duration or a database name on busy servers.
With QueryScope 2026.2.4 and later, an AI assistant connected to your IDE's MCP server can read execution plans, blocking chains and Query Store through QueryScope. Extended Events captures stay in the QueryScope tool window. See SQL Server MCP tools for your AI assistant in DataGrip.
Inside your JetBrains IDE
Reading ring-buffer XML by hand gets old quickly. QueryScope does the same capture from a tool window in IDEs with Database Tools, such as DataGrip, Rider and IntelliJ IDEA Ultimate, using the SQL Server data source you already configured.
- Install QueryScope from JetBrains Marketplace (30-day trial).
- Open the QueryScope tool window and pick your SQL Server data source.
- Start the capture and use your application as usual.
- Read duration, CPU, logical reads, writes and rows per query, filter by database, application, login or minimum duration, and group by query hash.
- Stop. The temporary session is removed. Export to CSV or JSON if you want to keep the results.

FAQ
Is SQL Server Profiler gone?
It is deprecated for the database engine. It still exists in older tooling, but Extended Events is the supported way to capture queries.
Which SQL Server versions does QueryScope support?
Query capture is verified on SQL Server 2022; other versions and Azure are experimental. The Query Store view needs SQL Server 2016 or later and the Blocking view SQL Server 2016 SP1 or later; both are tested on SQL Server 2019, 2022 and 2025.
More guides
Find and fix SQL Server blocking in DataGrip
Most of the time SQL Server is not slow: one session holds locks that others wait for. How to find that head blocker from DataGrip, decide what to do with it, read the deadlocks SQL Server already recorded and stop it from coming back.
Read the guide →SQL Server Query Store in DataGrip
A query that was fast yesterday is slow today, and nothing in the code changed: very often it got a different plan. How to check that Query Store is on, find the top resource consumers and regressed queries, read the plans and force the good one from DataGrip.
Read the guide →SQL Server MCP tools for your AI assistant in DataGrip
Give an AI assistant read-only access to SQL Server execution plans, current blocking chains and Query Store through the MCP server built into DataGrip and other JetBrains IDEs.
Read the guide →