Set variable from lookup activity result

Obaid UrRehman 166 Reputation points
2022-03-23T11:04:28.687+00:00

Hi,

I have a lookup activity in and ADF pipeline connected to a set variable activity:

185998-lookup.png

The query in lookup activity is:

Select name from [dbo].[someTable] where [ID] = '@{pipeline().parameters.pl_ID}'  

name is actually an integer

The idea is to query the database, set a variable already_exisiting_name equals to the result from the query

I have a variable current_name, if the alread_exsiting_name is equal to current_name then pipelines fails otherwise if already_exisitng_name is empty (as in this case, when there is no data yet in the db) the pipeline continues or if already_exisitng_name is smaller than current_name the pipeline continues.

When Iexecute the lookup activity, and examine the output, I dnt see any name field:
186072-executequery.png

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,739 questions
{count} votes

Accepted answer
  1. Nandan Hegde 29,901 Reputation points MVP
    2022-03-23T11:53:14.917+00:00

    Hey,
    In case of lookup activity in case if there is no data in your output below are the 2 ways output is visible:

    1. Disabling first row only
      186056-image.png

    2) Enabling 1st row only
    186057-image.png

    Based on your scenario, there might be cases wherein there might be no data or some data, so I would suggest disable the 1st row only property and have a below logic:
    IF count=0 meaning no data , so default assign your variable a value else pick up the 1st row value of the column


0 additional answers

Sort by: Most helpful