Using STRING_AGG() as a dynamic T-SQL generator

Concatenating strings is an essential practice in the dynamic T-SQL preparation process. A very common task is to generate multiple commands statements concatenated with UNION ALL, i.e. to calculate the number of rows in every table. The traditional way how to do it is that we will declare the @Stmt…

Read more

Saving Microsoft Forms responses to Azure SQL with Power Automate

One of our customers was facing the issue of how to save responses from Microsoft Forms to Azure SQL database. The initial idea was to go with Google Forms and Zappier but we have recommended the use of Microsoft Forms to stay inside the Azure environment instead of being split…

OdbcPrec() and OdbcScale() functions

I have discovered these two functions accidentally when searching for something else. I was trying to find more information about them but there is nothing in the official documentation and these function can’t be found in any metadata view like sys.all_object etc. It looks like they exist in SQL Server…

Calculating average value of multiple columns

It’s an easy task to calculate the average AVG() value for all rows in one or more columns. But it starts to be a little bit more interesting when we should calculate the average value for more columns on the same row. There are basically two options on how to…

Read more

Having fun with square brackets

This article is just for fun. From time to time T-SQL dialect may look like little bit scary. In the example below, we will create such a monster using square brackets. We will create a sample table and remove one square bracket in the column name. Let’s see what will…

Reporting Services samples for AdventureWorks2017

AdventureWorks is the sample database for SQL Server. It is updated with every new release of SQL Server major version and you can download it from its official location. Samples for SQL Server Reporting Services were built against this database long time ago and the most recent version can be…

Installing RabbitMQ on Windows

RabbitMQ is a trending message queue solution used by many software products today. From the release manager or CI/CD master point of view, it’s just another component that needs to be installed when delivering the product to the customer. Ideally, this should be automated but it depends on the customer…

Switch IP addresses between two Azure VMs

Changing an IP address of Azure virtual machines isn’t a complicated task. Simply locate the VM in Azure Portal and change the IP of it. A little bit more complicated is the scenario when we would like to switch IP addresses between two existing virtual machines. This scenario may be…

Using MERGE to override OUTPUT clause limitations

The OUTPUT clause is a very powerful extension of T-SQL included in SQL Server 2005. But from time to time it needs some tweaks or workarounds to get the expected result. One such example is using OUTPUT with INSERT statements. There is a limitation that only columns from the table…

Read more