I think you need to transform the array into a format that the SQL query can understand.
When you use @activity('lookup').output.value
, it returns an array of JSON objects like so:
[
{ "Id": "1" },
{ "Id": "2" },
{ "Id": "3" }
]
SQL expects the IN
clause to be in the form of (1, 2, 3)
. You'll have to transform your JSON array into a string that looks like that.
In the Set Variable activity, you can use this expression to transform the JSON array into a string like '1,2,3':
@string(join(',', array(map(activity('YourLookupActivityName').output.value, item => item.Id))))
This will give you a string variable (let's call it `IdsList`) that you can use in your SQL query.
Then, In your Copy activity, you'll then have to form the SQL query like so:
Select * from TableName where id IN (@{variables('IdsList')})
Please try and tell us !