Inserting Multiple Records In On Prem SQL Using Logic App

{tocify} $title={Table of Contents}


In last post we saw how to Insert a single Record in SQL Table which is on Prem using Logic App Inserting data in On Premises SQL Database using Logic Apps

Here I intend to walk through the process of inserting multiple records using single Logic App, to do this we have two options we can choose from 
1. Split On 
2. For Each

So either we debatch/split the Request message and insert in table or loop through the array of records and insert in table, here I am using the later method.


In earlier post we had single record  thus input was -
        "Description": "Edifice",
        "ID": "123",
        "Price": "3424"

Here we want multiple records thus we need to create an array of records as following-
        "Description": "Edifice",
        "ID": "123",
        "Price": "3424"
        "Description": "Edifice1",
        "ID": "1231",
        "Price": "2424"
        "Description": "Edifice2",
        "ID": "1232",
        "Price": "2344"
        "Description": "Edifice3",
        "ID": "1233",
        "Price": "2324"

Now let's create Logic App 

I have covered creating instance of Logic App  in last post so will directly go to creating Logic App,first step is to add the trigger to start the LA, a HTTP endpoint 
Request Trigger
The trigger is also supposed to accept Request message and for that there is provision to provide a schema for it (it is optional), in last post I haven't provided schema, here I intend to show the use of providing it. Click on Use Sample payload to generate schema, in the popped up editor provide the sample payload and click ok.
provide sample for schema

I’ve used the same payload as a sample message to generate the JSON schema.The JSON schema validates the incoming request and is useful for helping subsequent workflow steps know which properties to reference. Just like disassembler in BizTalk promotes properties here Trigger does that based on schema defined.
for each action

Add next action as For each, and as you can see above , Products is available as parameter to be used in For Each. Glad to see that apart from  Body(which is available to all ), Products which is an array is only available(which is valid parameter)

for each action setting

Select the Products and click on Add an action and add SQL connector . As am using same table used in previous post I don't have to specify connection details again rather would use same connection. 
select Sql action

Select Insert Row, you will see Product table gets available in dropdown list. Here if you see the properties which are valid for columns are available to choose from (Apart from Body) and this is because we have defined schema.
Insert row action

Assign appropriate properties against column and below is how it should look
for each settings

That's it, Logic app is ready for the task

Complete Logic App


For testing I have copied the URL (which you get on Request Trigger after save) and used ARC tool to send request- data is same which I used to create schema
Arc tool
On checking the LA run history, trigger was successful and LA too.

Logic App run history

If you go one level deep , you would see For Each step has four Insert Row within it(in sample four records were used) all successful(click on Next to see status of next Insert row action) 

for each run history

 Finally we need to verify the entries made in DB

multiple records entered in SQL

 As can be seen above all four records have made entry in table.

If you have questions or suggestions, feel free to do in comments section below !!!

Do share if you find this helpful .......
                         Knowledge Sharing is Caring !!!!!!

Learn More about Logic App

Post a Comment

If you have any suggestions or questions or want to share something then please drop a comment

Previous Post Next Post