Search code examples
sqlexpressionazure-data-factorygoogle-cloud-dataflowquote

ADF data flow concat expression with single quote


I need to generate a SQL string using Azure data flow expression builder, but it won't allow me to add a single quote between my string using Concat function

I need to have a SQL string as below

SELECT * FROM ABC WHERE myDate <= '2019-10-10'

Here 2019-10-10 is coming from a parameter, and so expression which I build is like below

concat('SELECT * FROM ABC WHERE myDate >=','''',$ToDate,'''')

but above statement unable to parse expression.

The result will be executed as a SQL query. SQL query doesn't allow double quote. It has to be single quote.

This is easily achievable using data factory expression but not with azure data flow expression.


Solution

  • Today, you can do it this way:

    'select * from saleslt.product where myDate >= \'' + $ToDate + '\''

    Essentially, just use + with escaped single quotes.

    We're releasing a new string interpolation feature next week to make this much easier. Any expression, column, or parameter can be used inside double-quotes.

    Your example will look like this:

    "SELECT * FROM ABC WHERE myDate >='{$ToDate}'"

    Much easier. I'll send out an announcement once the feature is ready next week.