Posts by Brent Ozar

How I Use the First Responder Kit

Updated First Responder Kit and Consultant Toolkit for February 2020

We spent Valentine’s Day removing the bugs from your chocolates. You’re welcome. To get the new version: Download the updated Azure Data Studio users with the First Responder Kit extension: ctrl/command+shift+p, First Responder Kit: Import. Download the updated Consultant Toolkit in your account EU customers: check your email for the updated version from Gumroad,…
Read More

WHERE GETDATE() BETWEEN StartDate AND EndDate Is Hard to Tune.

Say you’ve got a memberships (or policies) table, and each membership has start & end dates: Transact-SQL USE StackOverflow; GO DROP TABLE IF EXISTS dbo.UsersMemberships; CREATE TABLE dbo.UsersMemberships (Id INT IDENTITY(1,1) PRIMARY KEY CLUSTERED, UserId INT NOT NULL, StartDate DATETIME NOT NULL, EndDate DATETIME NOT NULL, CancelledEarlyDate DATETIME NULL); GO 1234567891011 USE StackOverflow;GODROP TABLE IF…
Read More

How to Pass a List of Values Into a Stored Procedure

Say we have a stored procedure that queries the Stack Overflow Users table to find people in a given location. Here’s what the table looks like: And here’s what my starting stored procedure looks like: Transact-SQL CREATE OR ALTER PROC dbo.usp_SearchUsersByLocation @SearchLocation NVARCHAR(40) AS SELECT * FROM dbo.Users WHERE Location = @SearchLocation ORDER BY DisplayName;…
Read More

What Should I Submit to the PASS Summit?

Our industry’s biggest conference, the PASS Summit 2020, just opened their pre-conference workshop call for speakers. I’m going to submit a couple of sessions, but I want to hear from you first: if you were going to try to convince your boss to buy you a pre-conference workshop at Summit, what would be the topics…
Read More

[Video] Watch Brent Tune Queries

Ever wonder somebody else does it? Watch over my shoulder as I spend 9 minutes in PowerPoint explaining the big picture, and then about 40 minutes working on this stored procedure in the StackOverflow2013 database: If you enjoy that, the Watch Brent Tune Queries page has another video and other query examples. Enjoy!
Read More

Building Removing Comments We have this PasteThePlan where you can copy/paste the contents of execution plans, and then share the links around the web. You’ve pasted 16,621 plans so far, and I’m always amused to see them continuing to trickle in every day without us actively promoting that tool. It just works, doing its thing quietly. Back…
Read More

Cool Query Hints

The SQL Server documentation has a pretty cool list of query hints: Yeah, I surf in dark mode. I’m a dark kinda guy. But wait – what’s that colored box? ENHANCE! I could make jokes here, but … every single thing in that caution is true. SQL Server really does typically select the best execution…
Read More