How to frame Dynamic Content Concatinate logic using Parameters in SQL Query - Azure Data Factory Pipeline

Kumar 41 Reputation points
2022-09-07T13:18:37.46+00:00

Hi Experts,

Struckup in configuring the syntax for the below query.

Sample SQL Query:
select column1, substr(fst_path, (instr(fst_path, 'JJJ_image_lib') + LENGTH('JJJ_image_lib'))), fst_index,
substr(bck_path, (instr(bck_path, 'JJJ_image_lib') + LENGTH('JJJ_image_lib'))), bck_index, s_id, s_seq, t_seq
from SCHEMA.TABLE where code = 'ABCD' and dept in ('A','B') and
fSt_index is not null order by t_seq, s_seq;

Requirement is: I want to pass the Code value dynamically - for this i have created Parameter at pipeline level and when i try to add this query in Pipeline --> Copy Activity --> Query --> Add Dynamic Content Query(Pipeline Expression Builder) - I;m getting some syntactical errors like missing commas or arguments etc and tried few options but still missing something hence seeking your advise.

I understand we need to use Concact operator as we have more conditions in where clause - So please share your thoughts how to frame above query in Query Add Dynamic Content.
238560-err-pic1.png

Appreciated your help, Thank You.

Regards,
Kumar P.

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
1,916 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,528 questions
Azure Data Lake Analytics
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,959 questions
{count} votes

Accepted answer
  1. Nandan Hegde 29,886 Reputation points MVP
    2022-09-07T15:12:18.15+00:00

    Hey,
    Please use the below query
    select column1, substr(fst_path, (instr(fst_path, 'JJJ_image_lib') + LENGTH('JJJ_image_lib'))), fst_index,
    substr(bck_path, (instr(bck_path, 'JJJ_image_lib') + LENGTH('JJJ_image_lib'))), bck_index, s_id, s_seq, t_seq
    from SCHEMA.TABLE where code = '@{pipeline().parameters.Test}' and dept in ('A','B') and
    fSt_index is not null ;

    No need of order by while copying, so excluded it :)

    Also the above code is w.r.t assumption you only needed to parameterise where code = '@{pipeline().parameters.Test}'

    and replace test with your parameter name


0 additional answers

Sort by: Most helpful