Sql-Server

Category: sql-server

Deadlock Code for the WideWorldImporters Sample Database

Deadlock Code for the WideWorldImporters Sample Database

If you haven’t checked out Microsoft’s new WideWorldImporters sample database for 2016, it’s a pretty cool new little database. The database makes it easy to play around with new 2016 features, and it even ships with some cool little executables to run inserts in the “workload-drivers” folder.

Continue reading

Unique Constraints vs Unique Indexes

Unique Constraints vs Unique Indexes

on September 8, 2016

Unique constraints and unique nonclustered indexes have a lot in common: unique constraints are implemented with a unique index behind the scenes.

While unique nonclustered indexes have a couple of additional features, I can still think of a scenario where it might be best to use unique constraints.

Continue reading

Estimated vs. Actual Number of Rows in Nested Loop Operators

Estimated vs. Actual Number of Rows in Nested Loop Operators

This is one of those little details that confused me a ton when I was first working with execution plans.

One problem with learning to work with plans is that there’s just SO MUCH to look at. And it’s a bit spread out. So, even when looking at a single tooltip, things can be confusing.

Let’s talk about the nested loop operator, who can be particularly weird to understand.

Continue reading

Do Clustered Index Columns Count Against Max Nonclustered Key Size?

Do Clustered Index Columns Count Against Max Nonclustered Key Size?

SQL Server 2016 and Azure SQL Database have a lot of little perks. One little thing that changed is that the maximum key size allowed for nonclustered indexes was raised from 900 bytes to 1700 bytes.

Continue reading

Teach Yourself SQL Server Performance Tuning (Dear SQL DBA Episode 12)

Teach Yourself SQL Server Performance Tuning (Dear SQL DBA Episode 12)

You’d love to have a job tuning SQL Servers, but you don’t have an environment to practice in. Here’s how to teach yourself performance tuning and prepare yourself to land and succeed in job interviews.

Continue reading

Altering an INT Column to a BIGINT (Dear SQL DBA Episode 11)

Altering an INT Column to a BIGINT (Dear SQL DBA Episode 11)

You need to change an INT column to a BIGINT in a large table. Learn why this schema change can make your transaction log explode, and how to avoid it.

Continue reading

How to Script Out Indexes from SQL Server

How to Script Out Indexes from SQL Server

Sometimes you need to script out all the indexes in a database. Maybe you’re concerned something has changed since they were last checked in. Or maybe the indexes aren’t checked into source control, and you’re working on fixing that. (Important!)

Either way, sometimes you need to do it, and it’s not fun through the GUI. I needed to write some fresh demo code for this recently, and I needed it to give the details for partitioned tables using data compression, and I thought I’d share.

Continue reading