web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to insert data tab...
Power Automate
Unanswered

How to insert data table into Database using Power Automate Desktop

(1) ShareShare
ReportReport
Posted on by 14
Using the Execute SQL statement action I have to pass the data table to MSSQL database, But I'm getting the exception.

Kindly assist me in the issue.
I have the same question (0)
  • Sayan Profile Picture
    818 Super User 2025 Season 2 on at
    Hey Rudhresh,
     
    Can you please share that what is the issue are you facing and what Query you want to execute.

    As the Query are somehow similar to SQL Query that we write in Sql server but when it comes to dynamic values during that time you will face difficulties.
     
    Please provide some examples with Screenshots so that I can help you to write the Query.
     
     
    -----------------------------------------------------------------------------------------------------------------------------------------------------
    Thanks,
    Sayan Patra
    RPA Developer
  • CU18110613-0 Profile Picture
    14 on at
    Hi Sayan, Thanks for replying. My scenario is I have fetched the data from MYSQL using Power Automate Desktop. The data contains two columns (Emp_ID, Employee_Name) and its type is data table. Now I want to insert that data table to Microsoft SQL. For the bulk insert we have created the stored procedure, For the stored procedure I have to pass this data table as an input. While passing I'm getting the error like
     
  • Parthiban759 Profile Picture
    56 on at
    Try this code in Run VB.net action and pass the necessary parameters
     
    Imports System.Data
    Imports System.Data.SqlClient
    Module Module1
        Sub Main()
            Dim connectionString As String = "your_connection_string"
            Dim dataTable As DataTable = GetDataTable() ' Assume this method gets your DataTable
            Using connection As New SqlConnection(connectionString)
                connection.Open()
                Using bulkCopy As New SqlBulkCopy(connection)
                    bulkCopy.DestinationTableName = "YourTableName"
                    ' Optionally, map columns
                    ' bulkCopy.ColumnMappings.Add("SourceColumn", "DestinationColumn")
                    Try
                        ' Write from the source to the destination.
                        bulkCopy.WriteToServer(dataTable)
                    Catch ex As Exception
                        Console.WriteLine(ex.Message)
                    End Try
                End Using
            End Using
        End Sub
        ' This function should be defined to get your DataTable
        Function GetDataTable() As DataTable
            Dim dt As New DataTable()
            ' Populate your DataTable here
            dt.Columns.Add("Column1", GetType(String))
            dt.Columns.Add("Column2", GetType(String))
            dt.Columns.Add("Column3", GetType(String))
            
            ' Add some sample data
            dt.Rows.Add("Value1", "Value2", "Value3")
            dt.Rows.Add("Value4", "Value5", "Value6")
            
            Return dt
        End Function
    End Module
     
  • CU18110613-0 Profile Picture
    14 on at
    Hi Parthipan, Thanks for replying. the code which you provided is not working. I'm getting this error

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard