Search for: subquery

Easy SQL mistakes: Accidental Correlated Subquery

Just a fun note, because it was a moment of pure puzzlement for me. I’m writing a new SP for Minion Backup (you knew it had to be Minion related, didn’t you?) and I just got the oddest error. Here’s how it went. First, I got a list of backups from the log: SELECT ExecutionDateTime , Status , PctComplete , […]

Varying Results with Subquery, ORDER BY, MAXDOP

In the speaker rooms of SQL events everywhere, there is wondrous blog material to be had, free for the picking up (as long as you attribute properly).  Speaking of which… Saturday in the SQL Saturday #63 Dallas speaker room, Erin Welker (blog) asked about a problem with a query that’s getting varying results depending on the MAXDOP […]

Compare tables to find missing rows

Let’s talk about the case where you want to compare tables to see what’s missing. We might be comparing a list of orders to an imported set of data in a staging table. Or, we’re identifying customers in the database that aren’t on the call list. Whatever the application, finding out the difference between one […]