Search code examples
foreachazure-data-factory

Get a list of values from SQL Server and pass it to For Each activity in Azure Data Factory (ADF)


I have a list of document numbers stored in a table in SQL Server database.

I want to pass these values to "For Each" activity in ADF.

I tried lookup activity and stored procedure activity but I'm unable to pass it to "For Each" activity as it expects an array.


Solution

  • I retrieved the docNumber column number using lookup activity with below query:

    select docNumber from docs
    

    The values fetched successfully. I pass those values into foreach activity with below dynamic expression:

    @activity('Lookup1').output
    

    Added setvariable activity in foreach activiy with below expression:

    @string(item().docNumber)
    

    When I execute the pipeline, I got the same error:

    enter image description here

    I changed the foreach activity item expression as mentioned below:

      @activity('Lookup1').output.value
    

    enter image description here

    And again, I executed the pipeline, it executed successfully without any error:

    enter image description here