Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass parameters to SQL query in Azure data factory

How can we pass parameter to SQL query in Azure data factory ...

ex: Select * from xyz_tbl where date between @date1 and @date2

if I use stored procedure with output @date1 and @date2 parameter, how can I pass these parameter to sql query.

like image 847
Jack Avatar asked Nov 14 '17 09:11

Jack


People also ask

How do you use parameters in data factory?

To add parameters to your data flow, click on the blank portion of the data flow canvas to see the general properties. In the settings pane, you will see a tab called Parameter. Select New to generate a new parameter. For each parameter, you must assign a name, select a type, and optionally set a default value.

How do I write a dynamic query in Azure data Factory?

To get started, open the create/edit Linked Service, and create new parameters for the Server Name and Database Name. Click in the Server Name/Database Name, text box field, and select Add Dynamic Content. Inside the Add dynamic content menu, click on the corresponding parameter you created earlier.


Video Answer


1 Answers

Which version of Azure DataFactory are you using, v1 ir v2?

If v2 is an option for you, you could achieve this by using Lookup activity that queries the database to get your dynamic properties and then referencing that activity's output in your sql query like so:

select * from from xyz_tbl 
where date between @{activity('LookupActivity').output.date1} 
and @{activity('LookupActivity').output.date2}

Here's a more detailed msdn tutorial for the Lookup activity: https://learn.microsoft.com/en-us/azure/data-factory/control-flow-lookup-activity

like image 156
Antonia Avatar answered Oct 25 '22 11:10

Antonia