Posts by Brent Ozar

How I Use the First Responder Kit

Updated First Responder Kit and Consultant Toolkit for February 2020

First Responder Kit Updates
0
We spent Valentine’s Day removing the bugs from your chocolates. You’re welcome. To get the new version: Download the updated FirstResponderKit.zip 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 Consultant Toolkit Changes Updated the First Responder Kit with this month’s…
Read More

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

Development, Indexing
19 Comments
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

T-SQL
61 Comments
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?

#SQLPass
5 Comments
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

Which SQL Server Enterprise Edition Should I Download?

When you’re downloading SQL Server, it’s important to choose Enterprise Core, not Enterprise. The plain “Enterprise” one is limited to just 20 CPU cores. But let’s say you didn’t know that, and you waltzed over to the download page. There are two Enterprises listed, and it’s not really clear what the differences are between the two:…
Read More

[Video] Watch Brent Tune Queries

Execution Plans, Videos
13 Comments
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

How to Remove Times from Dates in SQL Server

T-SQL
34 Comments
Say that you’ve got a table with a datetime column in it, like the LastAccessDate column in the Stack Overflow Users table: And let’s say you wanna find the users who last accessed the site on September 9, 2018 – regardless of the time. Here are a few ways to do it: Transact-SQL SELECT *…
Read More

Building PasteThePlan.com: Removing Comments

PasteThePlan.com
2 Comments
PasteThePlan.com 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

Why Database Monitoring Tools Are So Hard to Interpret

Monitoring
2 Comments
SentryOne’s Greg Gonzalez recently published a post about “Why Wait Stats Alone Are Not Enough.” Sure, Greg’s obviously biased towards his own monitoring tool, but his post is really well-written and fair. I want to explain the same story, but from a different (and simplified) angle. Say we’ve got a really simple database server, and…
Read More