SSMS Presenter Mode

SQL Server Management Studio (SSMS) release candidate 17.0 RC2 works side-by-side with generally available releases (16.x), but it is not recommended for production use. There are many enhancements which you can read here: but there is one feature I really like. It is called Presenter Mode and it is something I will use for my upcoming presentation. (Yes you read that right – might as well try presenting because apparently I like talking)

Continue reading


Setting up SQL Server to SQL Database (Azure) Replication

I had a need to setup transactional replication from my SQL Server to SQL Database (Azure) where I only needed a selection of tables that I wanted to off-load to Azure.  For this post I will be going through the setup, post checks with T-SQL / replication monitor, checking the incoming commands with Azure’s query performance insight tool and finally hooking it up to Power BI.

Continue reading

Lightweight Statistics Profiling (with a potential bug)

The great thing about new versions of SQL Server is the fact that they are packed full of new features but there some that don’t really get talked about much. I found out about a concept called lightweight query execution statistics profiling infrastructure – think of this as a way of capturing your “in-flight” query execution information, I did however encounter an issue which you will see later on.

Continue reading

Using Extended Events in Azure

Over the past 6 months I have been trying to push myself to use extended events (XEvents) over SQL trace, once you get past the learning curve it’s probably the way to go. If you are operating in the Azure space then you have no choice. Extended events are what you will need to use if you want to collect information against SQL database. There are some subtle differences on how you write the T-SQL between SQL database (Azure) and your locally installed SQL Servers.

Continue reading

SQL Server vNext

I have been pretty busy recently working with Joe Sack from Microsoft and  getting my hands dirty with SQL Server vNext accessing some cool stuff (which obviously I can’t talk about – under NDA) and believe me it is pretty powerful stuff.

Taking a step back vNext is going to be a big deal, bringing us new features such as support for running SQL Server on Linux (Red Hat, SUSE, and Ubuntu) and Docker containers, adaptive query processing, SQL graph, improvements to R Services, Analysis Services, Reporting Services, and Integration Services.

I was working with the most recent release SQL Server vNext CTP 1.2 (January 2017) and more specifically the adaptive query processing area and it is a powerful concept. Just helping the guys at Microsoft validate some things made me realise what amazing stuff is in the pipeline. Joe has already blogged about a section within this space called batch mode adaptive memory grant feedback. but I was working on something else <BIG SMILE>.

It really is an exciting time to be involved with the SQL Server product because I know there is more to come. It’s probably the right time to thank Joe for answering my questions and being very patient with me to really allow me to help them.

Hopefully I can keep helping with future releases of this product because from writing articles, blogging and building my codeplex project it is mini projects like this that really makes me smile. (Yes I include the SQLskills waits library in that too)

Thanks for reading!

Compare Execution Plans

Have you ever wanted to compare execution plans from SQL Server Management Studio? Well with the newer version of the software (SQL 2016 onward you can. Lets dive in.

Once you have an execution plan ready right click on it and you will see the show plan compare option.


You will then need to navigate to the other execution plan that you want to compare. Ultimately they will then be “side by side” to allow for easy comparisons.

There are basically 3 windows to this, your top plan (blue box), bottom plan (orange box) and the options menu (yellow box).


Or you can “toggle split” to change the orientation of the windows


As you can see in the yellow box I selected highlight similar operations, I then use the properties menu to see a high level comparison of the SELECT operator.


Notice the Wait stats information too? I thought that was pretty cool.

If you are interested in a certain operator that you want to compare you need to select it within both query plans and go to the properties window. Here I look at the hash match operator.


Then selecting the “highlight operators not matching similar segments” option you then will see where the execution plans differ. This was easy to see as the plan shape between the 2 plans was quite different.


This is a little feature that could prove quite handy.



I noticed that my backup was taking longer than usual.

I went to Perfmon to look at some counters, more specifically Physical disk:Avg sec/read(orange/yellow line) and Physical disk:Avg sec/write(blue line), yes it was very busy, much busier than normal.


Waits stats was painting the following picture: I was very intrigued with the sleep_bpool_flush so I headed straight over to the waits library.


You get this wait type when the checkpoint process realizes that it’s saturating the I/O subsystem. (, so it seemed that my backup could not even issue a checkpoint successfully. With that thinking I decided to do a manual checkpoint which just made the problem worse.


After some detective work I found the answer. Someone enabled TDE and it was going though the encryption process whilst I was trying to take a backup so my backup was never going to complete anytime soon.

The error message I was ended up with was  “Msg 5901, Level 16, State 1, Line 7 One or more recovery units belonging to database ‘NEWdb’ failed to generate a checkpoint”.

You can use the following query to understand the state of the encryption process for your databases.

sys.databases db
LEFT OUTER JOIN sys.dm_database_encryption_keys dm
ON db.database_id = dm.database_id


When you have a state of 2 it means encryption is in progress, you may have heard of this as an encryption scan.

This behaviour is confirmed via Books on line and totally makes sense. (Last bullet point)


  • Dropping a file from a filegroup in the database.
  • Dropping the database.
  • Taking the database offline.
  • Detaching a database.
  • Transitioning a database or filegroup into a READ ONLY state.
  • Using an ALTER DATABASE command.
  • Starting a database or database file backup.

You live and learn.