Categories: Azure Devops

Database Build Error – Incorrect syntax near DISTINCT

I wrote a piece of SQL that had some new T-SQL syntax in it: IS DISTINCT FROM. This predicate checks if two expressions are equal taking NULL into account. I successfully ran the code on an Azure SQL Database. However, when I tried to deploy the code using an Azure Devops pipeline, it returned the following error:

Error SQL46010: Incorrect syntax near DISTINCT.

That’s weird, it didn’t error out in SSMS or in Visual Studio (SQL Server Data Tools). I opened SSDT and rebuild the project. No build errors.

I went to the pipeline in Azure Devops and triggered it again. It completed successfully. That’s even more weird. After some trial and error, I found the culprit. When you trigger a pipeline manually, you get the following dialog:

The agent specification had windows-2019 (it’s been a while since I created the pipeline) and I had changed it to windows-latest.

When taking the latest version of Windows (and probably a more recent version of MSBuild), the error doesn’t occur. Probably the 2019 version doesn’t know about IS DISTINCT FROM, as it was released in 2022.

Conclusion: make sure to use either the latest version, or a recent stable version.


------------------------------------------------
Do you like this blog post? You can thank me by buying me a beer 🙂
Koen Verbeeck

Koen Verbeeck is a Microsoft Business Intelligence consultant at AE, helping clients to get insight in their data. Koen has a comprehensive knowledge of the SQL Server BI stack, with a particular love for Integration Services. He's also a speaker at various conferences.

Recent Posts

How to use a Script Activity in ADF as a Lookup

In Azure Data Factory (ADF, but also Synapse Pipelines and Fabric Pipelines), you have a…

2 days ago

Speaking at dataMinds Connect 2024

I'm very excited to announce I've been selected as a speaker for dataMinds Connect 2024,…

2 weeks ago

Dynamic Warehouse & Lakehouse Connections in Microsoft Fabric Data Pipelines

When you develop data pipelines in Microsoft Fabric (the Azure Data Factory equivalent in Fabric,…

2 weeks ago

System Views in Microsoft Fabric – Query references an object that is not supported in distributed processing mode

I have a metadata-driven ELT framework that heavily relies on dynamic SQL to generate SQL…

3 weeks ago

PostgreSQL error in Fabric Pipelines – No pg_hba.conf Entry for Host

I came across a bit of a weird error when I was trying to connect…

3 weeks ago

Book Review – Fundamentals of Data Engineering

This book was recommended by some of my colleagues, so I decided to give it…

3 weeks ago