I’ve recently started working on a project where we working in the cloud with Azure SQL Data Warehouse:
“Azure SQL Data Warehouse is a cloud-based, scale-out database capable of processing massive volumes of data, both relational and non-relational”
For more information about Azure SQL Data Warehouse, see here.
Although we develop with the same T-SQL as we do using the on-prem version of SQL Server, I did come across a bit of a quirk when writing some update statements.
If we are using the on-prem version of SQL Server, when we need to update data, we would have a SQL query like:
That is a basic update to a specific row of data in the Sales.MyOrderDetails table, using a where clause to filter for the row.
Sometimes, it isn’t always as straight forward and we need to join to other tables, so that we can refer to attributes from those rows for filtering purposes. For example:
However, if we take this approach in SQL Data Warehouse, we get the following error.
SQL Data Warehouse doesn’t support ANSI joins in the FROM clause of an UPDATE statement (it is also the case for DELETE statements too). There is a way round it and it uses an implicit join.
Before we look at how the update query can be written, it is a good place to point out that Inner joins can be written in a couple of different ways to what we had above.
In an inner join, the ON and WHERE clause both perform the same filtering and they both return rows where the ON and WHERE predicate is true. Therefore, we could write an inner join as
or implicitly like,
However, it is normally best to stick with the original example rather than the implicit version as although it is still supported, it is an old deprecated syntax and not considered best practise.
So, in order to write an update query in SQL Data Warehouse that uses inner joins to filter the rows, the workaround is as follows:
In conclusion, most SQL statements written in Azure SQL Data Warehouse are written in the same way we would with he on-prem version of SQL Server, however, there are some cases where the syntax differs slightly and I will be blogging more about these special cases as I come across them!
Meet the Team – Catherine Sachdev, Marketing Assistant
Next up we’re introducing you to Catherine Sachdev. Catherine joined us just over a year
Jan
Data Lineage with Azure Purview
I wrote an introductory Purview blog post previously, where I explored what the tool is
Jan
The Next Era of Retail: How Technology is driving change in a COVID-19 World
The retail sector is of great importance and accounts for almost 5% of GDP and
Jan
Meet the Team – Alex Kordbacheh, Junior Consultant
It’s time for another Meet the Team blog! This time we’re introducing you to Alex
Dec
Use cases for Recursive CTEs
Introductions Recursive CTEs are a way to reference a query over and over again, until
Dec
Azure Sentinel is named a ‘Leader’ in the Forrester Research Wave Report
Microsoft have recently announced that they have been named a Leader by Forrester Research in
Dec
Getting Started with Azure Purview
Azure Purview (a.k.a Data Catalog gen 2) has been released into preview and is currently
2 Comments
Dec
An Introduction to ApexSQL Complete – Integration with SSMS
We all know that the idea of add-ins is to make our lives easier. In
Dec