Find the biggest / smallest number

Finding the biggest or smallest value in a given set of values sounds quite easy, but can become tedious if the set is becoming bigger. This tip is not about aggregating values over rows, but rather finding the biggest or…

Translate for easy string replacements

Many times you need to replace certain characters in your strings. Normally, this is quite a tedious task and creates sql which is long and hard to read. As a simple example consider the following string “aaa<bbb><ccc{{ddd}}>“. We want to…

Calculating the last day of the month

To calculate the last day of a given month is either very easy or can be quite tricky – depending on the version of SQL Server you are using. Method #1 – eomonth() Just use the eomonth() function if you…

Calculating the first day of the month

Calculating the first day of the month based on a general date sounds very easy, but can be cumbersome. This article shows you various ways for doing it, using different methods. Method #1 – String manipulation This method is rather…