How to create csv file with date stamp and with a header (data from SQL) - Azure Data Factory

Anonymous
2022-12-21T01:15:45.61+00:00

I am trying to create a daily snapshot of data from Azure SQL into a newly created csv file.

What I did was just pointed an Azure file share folder as a destination, indicated "File extension" as .csv and ran the regular "Copy data" in Azure Data Factory.
272673-image.png

After I ran, what I realized was that the name of csv file is just the name of SQL object, and it did not have any date or time stamp on the csv file name itself.

And also, the csv file did not start with header from the source, but started with data on the 1st row.

What I am trying to do is create daily snapshot of SQL data into a new csv file.

So ideally, it would have the "name of object..2022_12_20..csv"

How do I go about doing it in ADF?

Here are requirements:

  1. Create a csv file with date/time stamp on the name of csv file (so that I could keep track of daily csv file).
  2. On the csv file, I would like to have the header (rather than first row starting from data).

Thanks.

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

Accepted answer
  1. Nelson Chimdiadi C 76 Reputation points
    2022-12-21T03:55:18.547+00:00

    To create a CSV file with a date stamp and a header using Azure Data Factory, you can follow these steps:

    In Azure Data Factory, create a new pipeline and add a Copy Data activity to it.

    In the Source tab, specify the source data store and the query that retrieves the data you want to include in the CSV file.

    In the Sink tab, choose "CSV" as the output format and specify the location where you want to save the file.

    To add a date stamp to the file name, you can use dynamic content in the file name field. For example, you can use the expression @{formatDateTime(utcNow(),'yyyyMMdd')} to generate a date stamp in the format YYYYMMDD.

    In the Columns tab, specify the column names and data types for the header. You can also specify the column delimiter, row delimiter, and other formatting options.

    Run the pipeline to create the CSV file with the date stamp and header.

    I hope this helps! Let me know if you have any questions or need further assistance.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nandan Hegde 36,146 Reputation points MVP Volunteer Moderator
    2022-12-21T03:19:08.447+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.