Azure Logic App Workflow SQL Execute Query to CSV file

user20201 346 Reputation points
2024-01-23T06:38:32.7966667+00:00

I am creating an Azure Logic App (standard) workflow that executes SQL query then save it as CSV and upload to Sharepoint. Please see below workflow.

The "Execute Query" is just a "Select requests" query from the Azure SQL database. Then the results will be the input in the "Compose" data operations. Then Initialize variable for the filename that have extension of ".csv" and will upload the output of that in the Sharepoint using "Create a file" action. But when I run this workflow, the uploaded csv file is just a single row excel file and no columns. Tried using the "Create CSV table" data operations actions but returns an error that the output from execute query is not an array. How can I configure the workflow or make the SQL query output as an array?

workflow

This is the CSV output:
csv output

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2024-01-25T11:09:37.59+00:00

    @user20201 Thanks for reaching out.

    You can leverage the Create CSV Table action and pass the ResultSets Table1 parameter from your execute a SQL query action. Now at your create file action use the outputs of your Create CSV table as below.User's image

    Please 'Accept Answer' if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.