Manasa Murugan
Manasa Murugan

Reputation: 35

Escaping single quotes in ADF dataflow

I am executing this query:

select * from schema.country where country_code='abc' and country='INDIA'

inside ADF dataflow. I am getting this query from the database so I don't want to hardcode it inside the data flow. All the data flow inputs are adding a single quotes while executing. The dataflow is failing because of parsing error.

How can I escape single quotes ?

Upvotes: 0

Views: 1871

Answers (1)

Rakesh Govindula
Rakesh Govindula

Reputation: 11529

You can just pass your query in double quotes ("") in the dataflow to escape single quotes.

Please go through the below 3 approaches based on your usage of query in the dataflow.

This is my sample data from database:

enter image description here

  1. If you are using Query in the source of dataflow, you can give the below expression in the Expression builder.

    "select * from [dbo].[country] where country_code='abc' and country_name='INDIA'"
    

    enter image description here

    Output Data preview:

    enter image description here

  2. If you want to get your query from your database, then create a stored procedure for the query and access it inside the dataflow.

    My stored procedure in the database:

    create or alter procedure dbo.proc2
    as
    begin
    select * from [dbo].[country] where country_code='abc' and country_name='INDIA'
    end;
    

    Use this query inside stored procedure in the dataflow like below. You will get the same output as above. enter image description here

  3. If you are using pipeline paramter to pass query to the dataflow, then create a parameter in the dataflow with default value. Give your query in double quotes in the pipeline parameters expression. Check the Expression check box after this.

    enter image description here

    Then give the $parameter1 in the expression builder of query and execute. Please check this SO thread to learn more it.

    My csv in sink after pipeline execution in this process:

    enter image description here

Upvotes: 4

Related Questions