Introduction Window Functions in SQL Server are functions which can be applied in the SELECT portion of a statement and will return a value relative to other records in the same data set. These functions differ from standard functions such as aggregates where those would combine multiple records together to come up with a result […]
Setting Default Values
Defaulting values is a typical part of data ingestion and processing within SQL. Handling NULL values can cause issues in a number of ways so there are time when we want to get these out of our data. Recently I had a question about setting default values for a field which was being processed as […]
Using Regular Expressions in SQL Server
After being around SQL Server for the last 15 years I was surprised recently to see an example of Regular Expression (RegEx) syntax being used within a SQL query and knew it was something I wanted to try out for myself. What are Regular Expressions? If you haven’t head of them before, Regular Expressions are […]
This month’s invitation from Steve is asking about strategies for upgrades with SQL Server. We might be more familiar with patching a SQL environment semi-regularly – and those processes may be tried and trusted – however its much rarer that we have the opportunity to uplift an entire environment to a later version. Here’s a […]
Using Schemas in SQL Server
Schemas within SQL server allow for logical separation of data within a single database. A schema is an extra layer which can allow objects in the database – including tables, views, procedures, etc. – to be separated. They could be used simply to group objects together in a more user-friendly way or they can be […]
Indexing Computed Columns
In the previous introduction post we covered how to add a computed column to a table and that by default this becomes part of the table metadata when its created. Here we’re going to look at benefits we can get with the performance of these columns when applying an index to them. We’ll use the […]
Altering Computed Columns
In a previous post we covered some of the fundamentals about computed columns and we saw the benefits which they can bring for us. Once we’ve implemented them, one of the challenges we may have is if we need to make adjustments to their expression or the fields they reference. Lets start off with a […]
This month’s invitation comes from Andy Yun who asked us to share something we’ve learned and which has subsequently changed our opinions. There were two immediate examples which came to mind, the first on a more technical note and the second somewhat more personal: “Table Variables Are Fast” Many years ago I’d found myself with […]
Introduction to Computed Columns
Using a computed column in a table allows you to have a calculation pre-baked into your schema. They also allow you to choose if you’d like that calculated value to be physically stored within the table (persisted) or to be calculated each time you query the table. To demonstrate this we’ll use a small sales […]
Deleting Data from a Heap
When it comes to removing data from a heap its pretty similar to removing it from a regular table: That’s all folks! Wait, or would you like your data pages back too? Yea, it might not be quite that easy… You see, when you remove a small number of records from a heap you’ll find […]