Sql-Server

Category: sql-server

ORDER BY, OFFSET, and Fetch in TSQL

ORDER BY, OFFSET, and Fetch in TSQL

By Kendra Little on June 29, 2018

My most recent Quizletter featured a quiz on ORDER BY in TSQL, complete with questions on the OFFSET and FETCH clauses which we got in SQL Server 2012.

One great thing about teaching TSQL School is that it reminds me of these cool options that can be easy to forget.

Continue reading

AVG() in TSQL: Watch Your Data Types

AVG() in TSQL: Watch Your Data Types

This week’s Quizletter featured a quiz on using the AVG() function in SQL Server.

I was inspired to write this quiz because I’ve been teaching “TSQL School” each week. When we covered aggregate functions, I remembered how tricksy AVG() can be.

Continue reading

Query Store Cleanup Can be Part of a Blocking Chain

Query Store Cleanup Can be Part of a Blocking Chain

By Kendra Little on April 18, 2018

Forgetfulness can lead to learning something new. This is a bit of a nightmare when it happens in production, but a treat when it happens in an isolated test system– and that’s how I learned this.

I left a bit of blocking open on my test VM, and forgot about it.

Continue reading

Adaptive Queries in Standard Edition: Interleaved Exec for Multi-Statement TVFs

Adaptive Queries in Standard Edition: Interleaved Exec for Multi-Statement TVFs

It’s tough to keep track of which features work in each version of SQL Server, and which Editions support them.

My memory told me that the new Adaptive Joins feature in SQL Server 2017 was Enterprise Edition only…  and that’s correct, but I didn’t realize that the fancy new feature to make Multi-Statement TVFs smarter has much wider licensing.

Continue reading

Auto-Tuning: Automatic Plan Correction is Cleared on Restart

Auto-Tuning: Automatic Plan Correction is Cleared on Restart

The new Enterprise Automatic Tuning feature in SQL Server 2017 may sound intimidating at first – one question I get a lot lately is whether or not there’s a future for DBAs. Will Auto-Tune mean we don’t need any more human tuning?

Well, not anytime super soon.

Continue reading

Why Is My Function Missing From sys.dm_exec_query_stats and Query Store?

Why Is My Function Missing From sys.dm_exec_query_stats and Query Store?

I just spent 90 minutes of my life figuring out a detail about sys.dm_exec_query_stats which I’m pretty sure I figured out five years ago, but didn’t write a blog post about.

Time to write a blog post, so I can save time when I go searching for this in a couple years.

Continue reading

The Case of MAX() Requiring an Index Scan, While TOP(1)/ORDER BY  DESC Does Not

The Case of MAX() Requiring an Index Scan, While TOP(1)/ORDER BY DESC Does Not

By Kendra Little on March 14, 2018

Most of the time in SQL Server, the MAX() function and a TOP(1) ORDER BY DESC will behave very similarly.

If you give them a rowstore index leading on the column in question, they’re generally smart enough to go to the correct end of the index, and – BOOP! – just pluck out the data you need without doing a big scan.

Continue reading