Decimal datatype rounding

Recently I was asked this question about how decimal is rounding off values when doing a simple calculation. The question was DECLARE @x DECIMAL(38, 0) = 0 DECLARE @y DECIMAL(32, 4) = 4.2 SELECT @x – @y –Output -4.2 DECLARE @x DECIMAL(37, 0) = 0 DECLARE @y DECIMAL(32, 4) = 4.2 SELECT @x – @y…

Identity value skips after restart

Recently a client of mine had complained to me about an issue they were facing when restarts happen on a system. After a restart the system skips the identity value by a 10 – 1000 depending on the data type of the identity column. This was a known issue in SQL 2012 and was touted…

Forcing Columnstore batch mode on Select * type query

Recently at a consulting project while working with tabular model I was asked about how we can force SQL Server to use batch mode on Columnstore index when doing a query which is essentially just a select *. To demonstrate this I have written two queries below which will return the same number of rows…

Weird ways I explain seemingly complicated SQL topics

Over the years I have accumulated some seemingly weird ways to explain topics within SQL Server. Usually in a training I find that participants are able to relate to an example in real life compared to some code written on the screen. While often the example might not be a perfect fit it still conveys…

Rebuild all indexes and statistics on Azure SQL database

Since Azure SQL databases are limited in what they expose to the management studio client we miss out on a lot of features within SSMS that we could normally use. One of the most common features we use frequently in this regard is the Rebuild Indexes and update statistics features within Maintenance Wizard. Below is…