T-SQL Ninja #53


EOMONTH What is EOMONTH? Date manipulations are always associated with pain for the inclined Ninja, as we have already noticed several times during the year. Therefore, there are numerous functions that can help. EOMONTH also belongs in this category and calculates the end of the respective month for a given date. How can you work with EOMONTH? […]

T-SQL Ninja #51


What is RAND? The RAND function gives you – not surprisingly – random numbers and is also one of the most used functions in T-SQL. However, the RAND function is a bit special, so we will look at how it behaves in certain scenarios below. How can you work with RAND? Let’s start with you generating a simple random […]

T-SQL Ninja #50


What does SELECT FROM VALUES actually do? Whenever you needed a small table to use for example for joins or something similar, we worked with temporary tables (hashtables, #-tables) here in the Dojo. The disadvantage of this is that if you want to run your script multiple times, you always had to drop these objects […]

T-SQL Ninja #49


What is CHOOSE? CHOOSE is certainly one of the less known functions in SQL Server, but this function is wrongly considered a shadowy existence, because it can make many annoying queries much easier. You can often use CHOOSE to simplify long, complex CASE WHEN statements, namely whenever you need to select an element from a list on the basis of […]

T-SQL Ninja #48


What does DATEDIFF do? Today we’ll look at one of the most well-known and really frequently used functions in SQL Server: DATEDIFF. The DATEDIFF function belongs to the functions for time objects, with it you can calculate the time between two datetime timestamps. You are free to specify the interval in years, months, days, hours, minutes, seconds, milliseconds […]

T-SQL Ninja #47


What is COMPRESS? If you have a large amount of data in a database that you no longer need, such as deleted records that you want to archive but are no longer used in your application, then it would be nice if this data was stored in compressed form. How you can achieve this with […]

T-SQL Ninja #46


What does MASKED WITH FUNCTION do? Let’s assume that you want to hide the real names of your ninjas from the enemy (as you should, of course). Let’s further assume that you want to know them and store them in a database. I know that this assumption becomes slightly abstruse here, as of course every […]

T-SQL Ninja #45


What’s a BULK INSERT? If you want to get larger amounts of data into a database, the wonder weapon in the SQL Server environment is of course SQL Server Integration Services. If you want to do this for a SQL database in the cloud, you don’t have an SSIS engine available for the time being, […]

T-SQL Ninja #44


What’s MAXDOP? You’ve probably noticed when viewing execution plans in SQL Server that there are often two small arrows on a yellow background (in SQL Server Management Studio) and the operation “Parallelism (Gather Streams)”. What this means, simply put, is that at some points SQL Server decides to execute certain operations in parallel in multiple […]

T-SQL Ninja #43


What is SP_RENAME? If you have objects in your database that you want to rename, you can right-click on the object in SQL Server Management Studio to rename it. However, if you want to make the renaming process a little more controlled and preferably distributable, then you can’t avoid scripting the process and don’t need […]