Categories
SQL

Querying with Aliases

When writing larger queries which return more fields or join together an increasing number of tables it can be easy for scripts to get unruly. A fundamental skill to help with the readablity of you queries is through the use of Aliases. An alias provides us a was to change how we reference part of […]

Categories
SQL

Performance Considerations using APPLY

In the previous post we looked at how to use the CROSS APPLY and OUTER APPLY operators as alternative to a JOIN in queries with some examples. As we wrapped that up I also mentioned that there can be drawbacks to using APPLY in our queries, particularly when we’re working with large data sets. The issue is due to the way that the right hand […]

Categories
SQL

Using Cross Apply and Outer Apply

When joining data in SQL we have a number of options to us including INNER and OUTER joins, but one of the ones I tend to use less frequently is the APPLY operator, specifically the CROSS APPLY and OUTER APPLY operators. As with other types of joins they operate slightly differently and have considerations which should be taken into account when deciding on the output […]

Categories
SQL

Complex Updates and Deletes

The UPDATE and DELETE statements allow us to manage the data within our databases and being able to use them effectively is key. There was recently a question from a junior developer asking about how to perform data changes when table joins are required so I thought it a good opportunity to put forward some more thought out details […]

Categories
SQL

Changing Object Schema in SQL Server

We’ve previously looked at the basics of using schemas in SQL Server where we created a schema and used objects inside of it. If you’re not dealing with new objects though and wanted to move something into or out of a schema how to we go about that? Not by renaming it For renaming most objects within […]

Categories
SQL

Challenges with Dynamic Data Masking

Recently we’ve been looking at Dynamic Data Masking and what it can achieve for us. With that said however, there are some drawbacks to how it works which its worth being aware of before you consider implementing it. Even in the official documentation it states that the feature “limits” exposure, can be used to “simplify” design, and […]

Categories
SQL

Dynamic Data Masking Patterns

When we initially looked at Dynamic Data Masking we used the default function to mask our data so it showed xxxx. With the masking however there are a few functions available to allow us to mask data in particular ways which may be of use depending on our use case. We’ll create a record to apply these masks against so […]

Categories
SQL

Introduction to Dynamic Data Masking

Given the abundance of data we deal with day to day its increasingly likely that we’ll find ourselves storing items of a more sensitive nature. We may only deal with details sensitive about our business such as suppliers or profitability, but when that increases – for example customer details – then we want to ensure […]

Categories
SQL

Testing Permissions with EXECUTE AS

When you’re developing a new database solution you’ll inevitably want to apply some security to that data. If you have complex security requirements with users being members of multiple groups or implementing multiple roles within the database it can become tricky to ensure that everything is working exactly as you like. It’s certainly a hassle […]

Categories
SQL

Additional Temporal Table Features

We’ve recently been looking at temporal tables, how they work, we query them and how to modify them. All of these are consistent since the feature was added in SQL Server 2016. There are however a couple of extra features which were added in 2017 to make these even more usable. Let’s use our previous […]