Ben
Ben

Reputation: 81

How to export from sql server table to multiple csv files in Azure Data Factory

I have a simple clients table in sql server that contains 2 columns - client name and city. In Azure Data Factory, how can I export this table to multiple csv files that each file will contain only a list of clients from the same city, which will be the name of the file

I already tried, and succeeded, to split it to different files using lookup and foreach, but the data remains unfiltered by the city

any ideas anyone?

Upvotes: 1

Views: 2579

Answers (2)

Nandan
Nandan

Reputation: 4925

You would need to follow the below flow chart:

  1. LookUp Activity : Query : Select distinct city from table
  2. For each activity
    Input : @activity('LookUp').output.value a) Copy activity i) Source : Dynamic Query Select * from t1 where city=@item().City

This should generate separate files for each country as needed

Steps: 1) enter image description here

  1. The batch job can be any nbr of parallel executions enter image description here

enter image description here

  1. Create a parameterised dataset: enter image description here

enter image description here

5) enter image description here

Result: I have 2 different Entities, so 2 files are generated.

Input :

enter image description here

Output:

enter image description here

Upvotes: 2

Leon Yue
Leon Yue

Reputation: 16401

You can use Data Flow to achieve that easily.

I made an example for you. I create a table as source, export this table to multiple csv files that each file will contain only a list of clients from the same city, which will be the name of the file.

Data Flow Source: enter image description here

Data Flow Sink settings: File name options: as data in column and use auto mapping. enter image description here

Check the output files and data in it: enter image description here

enter image description here

HTH.

Upvotes: 3

Related Questions