SQL Server

9 Ways to Lose Your Data

Every time someone tells me, “This database is mission critical – we can’t have data loss or downtime,” I just smile and shake my head. Technology is seriously difficult. To illustrate, here’s a collection of client stories from the last few years: The DBCC CHECKDB job ran every week just like it was supposed to…
Read More
Extended Events None Found

Extended Events Sessions: Messing Up Filters

SQL Server
8 Comments
Recently, I wanted to play around with the auto_stats event against a test system running SQL Server 2014. I ran through the session setup GUI and added the auto_stats event. I configured it with a filter (predicate) to only show me auto_stats event in a database named AutoStatsTest. There’s a cost to events that may fire frequently and a…
Read More

Using “OR” and “IN” with SQL Server’s Filtered Indexes

Indexing, SQL Server
4 Comments
You can’t do everything with filtered indexes in SQL Server. For instance, you can’t create the following index: Transact-SQL CREATE INDEX IX_Votes_filter ON dbo.Votes (PostId) WHERE (VoteTypeId = 1 OR VoteTypeId = 2); GO 123 CREATE INDEX IX_Votes_filter ON dbo.Votes (PostId)     WHERE (VoteTypeId = 1 OR VoteTypeId = 2);GO If you try, you’ll get the error…
Read More

Measuring Performance Can Slow SQL Server Down

SQL Server
9 Comments
I’ve written a terrible query. It might be the worst query in the world. Sure, there are other queries that may be slower, but this query is terrible and elegantly short. The query is gloriously bad for a two reasons: It’s incredibly inefficient in the way it uses a scalar function Observing the query’s performance can make…
Read More

Dropping an Offline Database in SQL Server

SQL Server
23 Comments
When you drop a database in SQL Server, the files are normally removed from the file system right away. POOF! Hope you had a backup if you ran DROP DATABASE against the wrong instance. However, things are a little different if you take the database offline before you drop it. Consider the following code: Transact-SQL…
Read More

Three reasons to use Extended Events

SQL Server
19 Comments
I have a new mission: to convince you, the long-time Profiler user, to switch to Extended Events. I realize I have a long, difficult task ahead of me. Profiler has been around for a long time. You’re comfortable with it. You know it’s not perfect, but you have learned to live with its imperfections. Now I want…
Read More

Are You Getting the Benefits of Virtualization?

Here’s some of the reasons companies usually virtualize their SQL Servers: Cost savings on hardware Cost savings on Windows OS licensing Cost savings on SQL Server licensing Protect against the failure of a single hardware element Leverage extended features for Disaster Recovery Automatic load balancing across multiple hosts Easier hardware replacement/migration When we perform a SQL Critical…
Read More
I ran headfirst into a brick wall.

How to Query Extended Events Target XML

SQL Server
26 Comments
When Extended Events (XE) were released with SQL Server 2008, I was excited – something new to learn! I read Microsoft articles about them, read blog posts about them, and tried to use them. At that time, there was no GUI for XE. I had to create the sessions with T-SQL. That wasn’t awful – I…
Read More

Testing ALTER INDEX REBUILD with WAIT_AT_LOW_PRIORITY in SQL Server 2014

One of the blocking scenarios I find most interesting is related to online index rebuilds. Index rebuilds are only mostly online. In order to complete they need a very high level of lock: a schema modification lock (SCH-M). Here’s one way this can become a big problem: An online index rebuild starts against a large index A…
Read More

We’re Hiring a Salesperson

Company News, SQL Server
3 Comments
When we first started our company, we laid out our goals in a shared Google Doc. We wrote about what we wanted to do, how we wanted to treat our employees and customers, and the growth numbers we wanted to achieve. One of our original goals was to hire one consultant per year. In 2012, it…
Read More