Posts by Brent Ozar

[Video] Office Hours: Bad Hair Edition

Videos
8 Comments
I am waaaay overdue for a haircut, but instead of being a responsible adult, I stopped to take your questions from https://pollgab.com/room/brento. 00:00 Start 00:43 Mike: We have 3 Dell PowerEdge R630 servers with SQL Server installed. Everything functions for 3.5 years straight. How long is it expected to work? 01:30 Shalom: What are the…
Read More

Office Hours: Bad Questions Edition

Videos
4 Comments
Normally, y’all post and upvote great questions at https://pollgab.com/room/brento, but in today’s episode, y’all upvoted some stinkers. Buckle up. 00:00 Start 00:47 SQLKB: Hi, according to sp_BlitzCache I usually have more than 260k plans in cache, created in the past 1 hour, is it a big number? Comparing number of plans from exec_query_stats vs exec_cached_plans…
Read More

3 Ways to Debug T-SQL Code

T-SQL
37 Comments
Writing new code = bugging. That part’s easy. Taking those bugs back out, that’s the hard part. Developers are used to their tools having built-in ways to show what line of code is running now, output the current content of variables, echo back progress messages, etc. For a while, SQL Server Management Studio also had…
Read More

How to Find Missing Rows in a Table

T-SQL
21 Comments
When someone says, “Find all the rows that have been deleted,” it’s a lot easier when the table has an Id/Identity column. Let’s take the Stack Overflow Users table: It has Ids -1, 1, 2, 3, 4, 5 … but no 6 or 7. (Or 0.) If someone asks you to find all the Ids…
Read More

The SQL Server Posts You Read the Most in 2022

Company News
3 Comments
Here’s what I wrote in 2022 that gathered the most views: #10: Who’s Hiring in the Database Community? February 2022 Edition – I saw the success of Hacker News’ “Who’s Hiring” monthly posts, and I blatantly stole the idea for the Microsoft data platform community. It works out well, very popular, very popular. #9: PSPO:…
Read More

[Video] Office Hours: Holiday Speed Round

Videos
0
Beep beep! Here’s a speed round of Office Hours where I rip through a dozen questions in under ten minutes. Want to see your own questions answered? Post ’em and upvote the ones you like at https://pollgab.com/room/brento. 00:00 Start 00:22 DB-A-Team: Love and appreciate your work and please don’t make fun of my question. I…
Read More
Brent Ozar Webcast

[Video] Office Hours: Ham Pillow Edition

Videos
2 Comments
Y’all post questions at https://pollgab.com/room/brento and upvote the ones you’d like to see me discuss, and then I artfully dodge giving you answers. At least, that’s how it feels sometimes, hahaha: Here’s what we discussed in today’s episode: 00:00 Start 00:20 Piotr: Do many of your clients disable SA account for security? What are your…
Read More

Should You Use SQL Server 2022’s GREATEST and LEAST?

SQL Server
2 Comments
If you’ve been following along with this week’s posts on DATETRUNC and STRING_SPLIT, you’re probably going to think the answer is no, but bear with me. It’s Christmas week, right? The news can’t all be bad. GREATEST and LEAST are kinda like MAX and MIN, but instead of taking multiple rows as input, they take multiple columns.…
Read More

Should You Use SQL Server 2022’s STRING_SPLIT?

T-SQL
2 Comments
SQL Server 2022 improved the STRING_SPLIT function so that it can now return lists that are guaranteed to be in order. However, that’s the only thing they improved – there’s still a critical performance problem with it. Let’s take the Stack Overflow database, Users table, put in an index on Location, and then test a…
Read More

Should You Use SQL Server 2022’s DATETRUNC?

T-SQL
10 Comments
SQL Server 2022 introduced a new T-SQL element, DATETRUNC, that truncates parts of dates. For example: SELECT DATETRUNC(year, '2017-06-01'); 1 SELECT DATETRUNC(year, '2017-06-01'); Truncates everything in that date other than the year, so it returns just 2017-01-01 00:00: You might ask, “Well, why not just use YEAR()?” That’s a good question – there are times…
Read More

[Video] Office Hours: Great Questions, Part 2

Videos
2 Comments
Every time I think, “There can’t be any more SQL Server questions left,” y’all post more great ones at https://pollgab.com/room/brento! Here’s what we covered: 00:21 MattC: Hi Brent. Have you check out ChatGPT’s ability to write SQL code. VERY impressive and in some cases faster than a stackoverflow question. In fact stackoverflow have had to…
Read More

Updated First Responder Kit and Consultant Toolkit for December 2022

Santa’s elves took a break from building toys and shipped a new version of the First Responder Kit. There are some great improvements in here, like a makeover for sp_BlitzLock and much better PSPO compatibility for sp_BlitzCache. Wanna watch me use it? Take the class. To get the new version: Download the updated FirstResponderKit.zip Azure…
Read More

[Video] Office Hours: Great Questions, Part 1

Videos
0
Wow, y’all have been posting some great questions at https://pollgab.com/room/brento lately! Here’s what we covered today: 00:59 Gustav: Hi Brent We recently migrated to SQL MI General Purpose, and I noticed that the default blob storage per .mdf /.ndf file is 128Gb container with 500 IOPS! This is terribly slow! Would splitting the database into…
Read More

Slow “Having” Query? Try Pre-Filtering.

T-SQL
11 Comments
I was helping a client with a query, and I’m going to rework the example to use the Stack Overflow database for easier storytelling. Say we need to: Find all the locations where users have logged in since a certain date, then Return the total count of people who live in those locations One way…
Read More

[Video] Office Hours: Speed Round Edition

Videos
0
I took a break from my Black Friday sale customer support emails to check in on the questions you posted at https://pollgab.com/room/brento and answer the highest-voted ones: 00:00 Start 00:15 Meshulam: What are the top use cases for running SQL Server in a container? Do many of your customers run SQL Server in a container?…
Read More

[Video] Office Hours: Black Friday Edition

Videos
0
My Black Friday sale is in its last days, so most of my time at the moment is spent keeping an eye on the site and answering customer questions. I’m happy to say it’s our best year so far, too! Y’all really like the new access-for-life options. I took a break from the online frenzy to…
Read More