Forum Discussion

amien's avatar
amien
Icon for Helper V rankHelper V
1 year ago
Solved

consuming a variable in a copy data job?

In a pipeline i run a notebook. In the end of this notebook i do a mssparkutils.notebook.exit

 

After the notebook is done, i have added a 'Set variable' with this setting : @activity('Notebook').output.result.exitvalue

This all works fine.

 

Now in my next step, i want to do a Copy data, using a query AND using the above mentioned variable. This part doesn't work.

I have this one in my query:

 

SELECT Week, Value FROM TableName WHERE Week = @variables('Maxweek_')

 

Is this not correct?

 

 

  • I think the syntax should be something like...

     

    @concat(
    'select week, value from TableName where week = '
    , variables('Maxweek_')
    )

     

    depending on how you've written your variable, you may need to enclose it in quotes, and the escaping of quotes can be confusing...

     

    @concat(
    'select week, value from TableName where week = '
    , ''''
    , variables('Maxweek_')
    , ''''
    )

     

    So that '''' is surrounding the concat item in '' and then another '' one to escape the other.

     

  • Yeah, you need to use the add dynamic content option for this.

     

     

4 Replies

  • KNP's avatar
    KNP
    Icon for Super User rankSuper User

    Yeah, you need to use the add dynamic content option for this.

     

     

  • KNP's avatar
    KNP
    Icon for Super User rankSuper User

    I think the syntax should be something like...

     

    @concat(
    'select week, value from TableName where week = '
    , variables('Maxweek_')
    )

     

    depending on how you've written your variable, you may need to enclose it in quotes, and the escaping of quotes can be confusing...

     

    @concat(
    'select week, value from TableName where week = '
    , ''''
    , variables('Maxweek_')
    , ''''
    )

     

    So that '''' is surrounding the concat item in '' and then another '' one to escape the other.

     

    • amien's avatar
      amien
      Icon for Helper V rankHelper V

      it does work (first option) .. only thing is that it will remove the 'edit' button 🙂

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi amien ,

     

    Did KNP reply solve your problem? If so, please mark it as the correct solution, and point out if the problem persists.

     

    Best regards,

    Adamk Kong