Skip to content

You can’t DELETE TOP (x) with an ORDER BY

'Did you know you can’t do this?
1
2
3
DELETE TOP (10)
FROM SalesOrderDetail
ORDER BY SalesOrderID DESC;

Msg 156, Level 15, State 1, Line 8
Incorrect syntax near the keyword ‘ORDER’.

I didn’t. Until I tried it anyway. Turns out, it says so right in the limitations section of BOL. Fortunately, that same section does have a recommendation on how to move forward.'...

https://sqlstudies.com/2018/09/19/you-cant-delete-top-x-with-an-order-by/

Extended Events and Stored Procedure Parameter Values

'One complaint I’ve received frequently is that you can’t see stored procedure parameter values in Extended Events. That is patently not true. However, it does depend on where and how you capture the events and which stored procedure parameter values you’re going for. I think this is a holdover from 2008 when Extended Events… well, let’s be kind and say… didn’t work well. Now, they do. Let’s explore this a little.'...

https://www.scarydba.com/2018/09/24/extended-events-and-stored-procedure-parameter-values/

Troubleshooting Query timeouts in SQL Server

'While working with SQL Server, one of the common issue application teams encounter is timeouts. In this article, we are covering approach to troubleshoot SQL Command/Query timeouts, data collection and data analysis steps to isolate further.

There are 2 types of timeouts.

  1. Command Timeout

  2. Connection Timeout.'...

https://blogs.msdn.microsoft.com/docast/2018/10/12/troubleshooting-query-timeouts-in-sql-server/

SQL Server 2017 CU3 adds tempdb spill diagnostics in DMVs and Extended Events

'Whenever I’m teaching people about query tuning, two things come up almost without fail: parameter sniffing and tempdb spills.

They’re not mutually exclusive — some queries will seemingly always spill to tempdb, whether parameter sniffing is present of not, and some queries experiencing issues with parameter sniffing will never spill to tempdb.

The tough part is that catching parameter sniffing in action is difficult. It’s sort of like looking for it makes it disappear, and some evidence of it still disappears.

This has improved both with the addition of Query Store in general, and memory grants in DMVs.

Now with tempdb spills added, your job gets even easier. Sort of.

The finding problems part is easier.'...

https://www.brentozar.com/archive/2018/01/sql-server-2017-cu3-adds-tempdb-spill-diagnostics-dmvs-extended-events/

Developers Choice: Query progress – anytime, anywhere

'One of the most important actions when a performance issue hits, is to get precise understanding on the workload that’s executing and how resource usage is being driven. The actual execution plan is an invaluable tool for this purpose.

Query completion is a prerequisite for the availability of an actual query plan, but with LQS (Live Query Statistics), you can already get information about in-flight query executions (see this blog post), which is especially useful for long running queries, and queries that run indefinitely and never finish.'...

https://blogs.msdn.microsoft.com/sql_server_team/query-progress-anytime-anywhere/

Adaptive Query Processing in SQL Server 2017

'As new versions of SQL Server have been released, the Query Optimizer has undergone many improvements. Adaptive Query Processing, new in 2017, represents a new direction. This set of features provides some flexibility for varying join types, multi-statement table valued functions, and memory grants. In this article, Robert Sheldon explains the three features that make up Adaptive Query Processing'...

https://www.red-gate.com/simple-talk/sql/database-administration/adaptive-query-processing-in-sql-server-2017/