SQL Server 2025 Series : ABORT_QUERY_EXECUTION Explained with Full Live Demo!

If you manage production workloads, you’ve probably seen situations where one problematic query keeps hurting performance for everyone else. In SQL Server 2025, Microsoft highlights ABORT_QUERY_EXECUTION as a Query Store hint that lets administrators block the future execution of a known problematic query without changing application code. That makes it a practical DBA-focused safeguard when you need control quickly.

In this blog, I’ll explain what ABORT_QUERY_EXECUTION is, why it matters, the prerequisites, and then walk through a full live demo using only the code shown below. I’ll also show how to verify whether the hint is configured and how to list blocked queries recorded in Query Store. Microsoft’s product and demo references position this feature as part of the broader query-processing and administrative control improvements in SQL Server 2025.


What is ABORT_QUERY_EXECUTION?

ABORT_QUERY_EXECUTION is a query hint showcased for SQL Server 2025 that can be applied through Query Store hints to block future executions of a specific query. The available Microsoft and demo references consistently describe it as an administrative control for stopping a known bad query from continuing to impact workload stability, while avoiding application code changes.

One important clarification: this feature is described as preventing future executions of the targeted query. The references do not describe it as a general-purpose replacement for terminating a query that is already running.


Why was this introduced?

The purpose is simple and practical. Sometimes a query is known to be expensive or disruptive, but the application team cannot change the code immediately. In that situation, Query Store hints already provide a way to influence query behavior without redeploying code, and ABORT_QUERY_EXECUTION extends that model by allowing the query to be blocked from future execution.

Available references describe this feature as a way to stop rogue or problematic queries from harming the rest of the workload and to improve reliability during incidents. That is what makes it a useful operational safety valve for DBAs.


Prerequisites

Before testing this feature, the main prerequisite is that Query Store must be enabled, because ABORT_QUERY_EXECUTION works through Query Store hints. This requirement is explicitly reflected in the demo references and supporting guidance.

For this walkthrough, you need:

  • SQL Server 2025
  • A database where your demo query can be captured in Query Store
  • Query Store enabled for that database

Full Demo Code

-- ABORT_QUERY_EXECUTION
CREATE OR ALTER procedure [dbo].[usp_procdisplaydata] @Col2 int
as
begin
SELECT top (150000)
[Col1],
[Col2],
[Col3],
[Col4],
[Col5]
FROM dbo.Table1
WHERE [Col2] = @Col2
ORDER BY [Col3];
END
EXEC [dbo].[usp_procdisplaydata] @Col2=2
SELECT TOP (20)
q.query_id,
qt.query_sql_text,
rs.count_executions,
rs.avg_duration,
rs.last_duration
FROM sys.query_store_query_text qt
JOIN sys.query_store_query q
ON qt.query_text_id = q.query_text_id
JOIN sys.query_store_plan p
ON q.query_id = p.query_id
JOIN sys.query_store_runtime_stats rs
ON p.plan_id = rs.plan_id
WHERE qt.query_sql_text LIKE N'%SELECT top (150000)%'
ORDER BY rs.last_execution_time DESC;
GO -- Query Id 38
EXEC sys.sp_query_store_set_hints
@query_id = 38,
@query_hints = N'OPTION (USE HINT (''ABORT_QUERY_EXECUTION''))';
GO
SELECT *
FROM sys.query_store_query_hints
WHERE query_id = 38;
GO
EXEC [dbo].[usp_procdisplaydata] @Col2=2
EXEC sys.sp_query_store_clear_hints
@query_id = 38;
GO
-- Blocked queries in Query Store
SELECT qsh.query_id,
q.query_hash,
qt.query_sql_text
FROM sys.query_store_query_hints AS qsh
INNER JOIN sys.query_store_query AS q
ON qsh.query_id = q.query_id
INNER JOIN sys.query_store_query_text AS qt
ON q.query_text_id = qt.query_text_id
WHERE UPPER(qsh.query_hint_text) LIKE '%ABORT[_]QUERY[_]EXECUTION%'

Step-by-Step Demo Explanation

1) Create the procedure and execute it once

The first part of the demo creates a stored procedure and executes it so the query text is captured in Query Store. That step is important because the feature is implemented through Query Store hints, and you need the corresponding query_id before you can apply the hint.

2) Find the query in Query Store

The next query searches the Query Store catalog views using the text pattern SELECT top (150000) to identify the relevant query and retrieve its query_id. In this demo script, the query id used is 38. The overall approach aligns with the feature’s dependency on Query Store metadata.

3) Apply ABORT_QUERY_EXECUTION

The core configuration step is:

EXEC sys.sp_query_store_set_hints
@query_id = 38,
@query_hints = N'OPTION (USE HINT (''ABORT_QUERY_EXECUTION''))';

This applies the ABORT_QUERY_EXECUTION query hint through Query Store for the specific query. The available demo and product materials explicitly show this feature being implemented through sp_query_store_set_hints.

4) Verify that the hint is configured

The following verification query checks the Query Store catalog view for the configured hint:

SELECT *
FROM sys.query_store_query_hints
WHERE query_id = 38;

This is a practical way to verify whether ABORT_QUERY_EXECUTION has been configured for that query in your database.

5) Execute the procedure again

After the hint is applied, the procedure is executed again so you can validate the configured behavior. Based on the available references, ABORT_QUERY_EXECUTION is designed to block future executions of the targeted query once the hint is in place.

6) Clear the hint

Once testing is complete, the hint is removed using:

EXEC sys.sp_query_store_clear_hints
@query_id = 38;

This completes the full end-to-end lifecycle: identify the query, apply the hint, verify it, test it, and clear it when it is no longer needed.

7) List blocked queries in Query Store

The final query in the script looks for entries in sys.query_store_query_hints where the configured hint text contains ABORT_QUERY_EXECUTION. This is useful when you want to audit or review queries that have been configured with this hint

SELECT qsh.query_id,
q.query_hash,
qt.query_sql_text
FROM sys.query_store_query_hints AS qsh
INNER JOIN sys.query_store_query AS q
ON qsh.query_id = q.query_id
INNER JOIN sys.query_store_query_text AS qt
ON q.query_text_id = qt.query_text_id
WHERE UPPER(qsh.query_hint_text) LIKE '%ABORT[_]QUERY[_]EXECUTION%'

ABORT_QUERY_EXECUTION is one of the more practical DBA-oriented capabilities highlighted in SQL Server 2025. It gives administrators a way to block the future execution of a known problematic query using Query Store hints, without changing application code. That makes it especially valuable when immediate workload protection is needed.


Watch the Full Demo

I’ve recorded a complete walkthrough of this setup on my YouTube channel JBSWiki. If you’re a visual learner, go check it out!

👉 Watch here: https://www.youtube.com/watch?v=SjjC18u-jjM


Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

I Built a Personal Meeting Assistant in Minutes – Copilot Workflows (Frontier)

How many minutes do you spend every morning scanning your Outlook calendar, figuring out which meetings need your attention and which ones you can skip? For most of us, it’s a daily ritual that quietly eats into productive time.

What if I told you that you could automate this entirely — and it takes less than 5 minutes to set up?

Enter Workflows (Frontier), a powerful agent inside Microsoft Copilot that lets you build scheduled automations using plain English. No Power Automate connectors. No code. Just describe what you want, and Copilot does the rest.


What I Built

I created a workflow that runs every weekday at 08:00 AM IST, reviews my entire Outlook calendar for the day, and sends me a neatly organized summary as a Teams message — before I even open my first app.

Here’s the exact prompt I used:


“Every weekday at 08:00 AM IST, review all meetings scheduled on my Outlook calendar for the day and send me a summary as a Microsoft Teams message.

For each meeting, include the following details:

  • Meeting title
  • Start and end time
  • Meeting organizer
  • Required attendees
  • Whether I am listed as a required attendee

Organize the response into two sections:

  1. Meetings where I am the organizer or a required attendee
  2. Meetings where I am not a required attendee

Within each section, sort the meetings by start time in ascending order.”


That’s it. One prompt. The Workflows (Frontier) agent takes care of everything — reading your calendar, extracting meeting metadata, categorizing meetings based on your role, sorting them by time, and delivering the final summary to Teams.


Why This Matters

As someone who juggles 8–12 meetings on a busy day, this small automation has had an outsized impact on my mornings:

  • No more calendar scanning — I get a clean, prioritized view of my day in Teams before I even start working.
  • Instant clarity on priorities — Meetings where I’m a required attendee or organizer are listed first, so I know exactly what demands my focus.
  • Reduced meeting surprises — The “not a required attendee” section helps me decide which meetings I can skip or follow asynchronously.
  • Zero effort, every day — It runs on autopilot, weekdays only.

What is Workflows (Frontier)?

Workflows (Frontier) is an agent within Microsoft Copilot that allows you to create automated, scheduled, or event-triggered workflows using natural language prompts. It connects seamlessly with Microsoft 365 services — Outlook, Teams, OneDrive, and more — making it incredibly easy to automate repetitive tasks without writing a single line of code.

Think of it as having a personal assistant that follows your instructions to the letter, every single day, without reminders.


What Else Can You Automate?

The possibilities are endless. Here are a few ideas to get you started:

  • 📧 Daily email digest — Summarize unread emails from key stakeholders every morning
  • 📁 Weekly file roundup — Get a Teams message listing all files shared with you in the past week
  • ✅ Meeting follow-up — After every meeting, auto-send a summary of action items to attendees
  • 📊 Status reminders — Send yourself a Friday afternoon prompt to update your weekly status report

🎬 Watch the Full Demo

I’ve recorded a complete walkthrough of this setup on my YouTube channel JBSWiki, where I demo the workflow live — from prompt to Teams delivery. If you’re a visual learner, go check it out!

👉 Watch here: https://www.youtube.com/watch?v=8ayDKHN4ALo


Final Thoughts

We often chase big productivity hacks, but sometimes the biggest wins come from eliminating small, repetitive tasks. This 5-minute setup saves me 10–15 minutes every single workday. Over a year, that’s 40+ hours reclaimed — just from automating a morning calendar review.

If you’re using Microsoft 365 with Copilot, give Workflows (Frontier) a try. Start with the prompt above, tweak it to your needs, and let AI handle the mundane so you can focus on what matters.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.