Select Page

Merge Statements

Over the years I have come across a lot of merge statements and I find most of the time there is one fundamental flaw in how it is written by most people. In the update section in most cases I find that there is no section there to check if anything has changed...

Querying Data in Temporal Tables

Following on from my previous post about modifying data in a temporal table, I will be looking into querying the data in this post. When you want to get latest (actual) state of data in a temporal table, you can query the same way as you query a normal table. If the...

Modifying Temporal Tables

Following on from my previous post about Temporal Tables, this post talks about modifying temporal tables. Data in a temporal table is modified using regular DML statements with one important difference: the period column data cannot be directly modified. When data is...

Temporal Tables

Let’s start off with what is a temporal table? SQL Server 2016 introduced support for system-versioned temporal tables as a database feature that brings built-in support for providing information about data stored in the table at any point in time rather than only the...

Inline Table-Valued Functions (TVFs)

Lets start off with what is a table-valued function (TVF)? A TVF is a dynamic table produced at the time of execution, depending on parameters. Like a view, a TVF creates a result set only when it’s executed, but, unlike a view, it can be parameterized. You get two...

Index on Key vs Included

Indexing can be quite confusing at times if you not 100% sure on what to do. Do you just index on key or do you add included columns? Well this depends on what you are doing and what type of performance improvement you are looking for. Lets start with some history,...