Categories
SQL

Effectively Deploying Stored Procedure Changes

If writing code is the meat of our work then then packaging our stored procedures for deployment is the bread and butter to complete the sandwich. Deploying them is key so here we’ll be looking at options for how to effectively script those changes. The specific challenge we’re looking at here is how to change […]

Categories
SQL

More Caring, More Sharing: Handling Datasets within Sessions

When building data solutions we’ll be handling sets of data which may need to be imported, transformed, aggregated or exported amongst other things. With more complex solutions can come a need to share this data between different areas of the process. Last week we looked at being able to share individual values within a session and […]

Categories
SQL

Sharing is Caring: Exchanging Values within Sessions

When developing application code we may be familiar with exchanging data and objects through the application. This practice is much less common in SQL due to being transactional when we consider application / OLTP workloads. There are however some times when exchanging values between code in the same session which is what we’ll start to […]

Categories
SQL

Utilising Bit Masks with Bitwise Operators

A few weeks back we looked at options for storing multiple boolean flag values in a table. One of the options we considered was the use of a Bit Mask where we packed multiple flags into a single field. When we have individual fields within a table, using and manipulating those is straightforward. However when we’ve got […]

Categories
SQL

Designing Long Running Procedures for Maintainability

Whilst we have front-end code which requires faster response times, there are also times we build code with the purpose of running for extended periods of time. Examples of this could be maintenance routine, or custom built queuing mechanisms. The way in which we design longer running processes like this can be key when it […]

Categories
SQL

Calculating String Lengths

We store a wide variety of data within our platforms, some of which will inevitably be string based. Along with that comes a need to perform manipulation of those strings. When slicing, combining, or manipulating strings one element which we need to consider is the length of the string. Here I wanted to have a […]

Categories
SQL

Recursive Functions and Limitations

When writing functions within SQL Server we sometimes have need to repeat an action multiple times until a given condition is met – also known as Recursion. There are a couple of common ways which this can be implemented which also have their different limitations. A little about recursion Firstly, why do we need recursion? […]

Categories
SQL

Schema Design for Bit Flags

When designing a data schema to store a variety of entities it can be common to require a selection of flags to be stored. There are different ways in which the data can be designed to accommodate this which I wanted to look at here. Examples of these fields could be an ‘Is Active’ flag […]

Categories
SQL

Ranking Function Reference

When processing data there is frequently a need to rank the outputs. This could be to limit a selection of records to return, or provide a type of leader-board for reporting. There are a number of ranking functions within the SQL language which we’ll look at here with examples and outputs. We’ll start with some […]

Categories
SQL

Alternative to Binary Case Statements

When outputting data through a procedure it’s a common use case to add fields which have been calculated from existing data. One way to achieve this is using the CASE statement, however we don’t always need that level of complexity, particularly when we’re looking for a binary result such as ‘Yes’ / ‘No’. An alternative […]