Categories
SQL

Optimising DISTINCT Clauses using EXISTS

The DISTINCT clause in a query can help us quickly remove duplicates from our results. Sometimes it can be beneficial to stop and ask why. Why do we need to use the clause, why are we receiving duplicates from our data? I see this typically due to a JOIN being used where we don’t really want all of those results. This could […]

Categories
SQL

Solving Deadlocks with Application Locks

Deadlocks are an enduring feature of SQL Server. They’ve been a source of pain for many over the years and there are various ways to diagnose, mitigate or resolve them. Here I want to demonstrate approach I haven’t seen discussed – using an application lock to segregate processes. An example where I’ve used this effectively […]

Categories
Personal

2023 Year in Review

Looking back at the year that has been and the year ahead

Categories
T-SQL Tuesday

T-SQL Tuesday #170 – Learning the Hard Way

This month’s invitation from Reitse asks us to talk about learnings from abandoned or failed projects. This one will sit somewhere squarely between those two points. It was an opportunity to learn about scalability. Let’s set the scene. A point of sale system being rolled out across hundreds of physical locations. Transaction data collected each night to […]

Categories
SQL

A Focus on TRY_PARSE Functionality

In the previous post we looked at the functions TRY_CAST, TRY_CONVERT, and TRY_PARSE and how they compared. I wrapped up and said that my preference for new developments would be to use TRY_PARSE due to the tighter control which it provides us. As with everything in SQL Server however, there is no ‘best’ approach, it depends. I therefore wanted […]