Azure Data Factory - Where is For Loop to loop on a counter

Jay 506 Reputation points

I want to create a pipeline that runs a store procedure which populates a table with 0 to 10 rows, I then want to select each row and email the row (logic app) 1 row per email.

I'm stuck on the For Loop...

My sql table has a row number so I can do a lookup: SELECT max(RN) as MaxRN FROM [dbo].[table]
And I thought I could set a variable as 1 and just loop until variable greater than lookup value but I can't see how to do this easily in for each.

Also within the loop I was going to get the sql table row to email by simply: SELECT Value1,Value2 FROM [dbo].[table] Where RN = variable

Is this possible what I'm attempting?


Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
6,332 questions
No comments
{count} votes

Accepted answer
  1. svijay-MSFT 5,111 Reputation points Microsoft Employee

    Hello @Jay ,

    Thanks for the question and using MS Q&A platform.

    My understanding is that you'd like to loop in values from 1 to 10 in a variable.

    You could make use of the Range Function


    In the Foreach Activity


    You could Reference each value of the iteration using the Current Item.


    Hope this will help. Please let us know if any further queries.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

0 additional answers

Sort by: Most helpful