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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Execute SQL Statement ...
Power Automate
Answered

Execute SQL Statement error, Excel

(0) ShareShare
ReportReport
Posted on by 9

SQL Statement:

INSERT INTO [dbo].[WebADI_File_Data]
([Id]
,[Power_Automate_Log_Id]
,[Upl]
,[Payment_Method]
,[Customer_Taxpayer_ID]
,[Legal_Entity]
,[Supplier_Number]
,[Payment_Terms]
,[Supplier_Site_Name]
,[PO_Number]
,[Quantity_Invoiced]
,[Invoice_Number]
,[Invoice_Comments]
,[Invoice_Description]
,[Invoice_Date]
,[Invoice_Total]
,[Line_Number]
,[Line_Description]
,[Line_Amount]
,[Tax_Code]
,[Project_Number]
,[Task_Number]
,[Expenditure_Type]
,[Expenditure_Item_Date]
,[GL_Account]
,[Expenditure_Organization]
,[Code_Of_Account]
,[Messages]
,[IsUploaded])
VALUES
(NEWID(),'F8CE65AF-1906-40C8-B0E4-AB7A9BD625B9','','','',80054,173661,'Pay When Paid','PO BOX 820','',%Quantity_Invoice[Index]%,%InvoiceNumber[Index]%,'','','',%Invoice_Total[Index]%,'',%LineDescription[Index]%,%Invoice_Total[Index]%,'No Tax',%Project_Number[Index]%,'','9232-Subcontract(Construction)','7/25/2023','','800544103800570901 USA - HOUSTON','','',0)


I tried putting this string value ' GIS Labour 3.5 Hrs INV10525169' directly in place of %LineDescription[Index]% and the same query worked

Column Data Type  <Line_Description, nvarchar(100),>


Output of variable %LineDescription[Index]% -

NiyatiNautiyal_0-1695779422821.png

 

Error:

Correlation Id: 02ce7dc2-d6db-490d-bcab-902863716ee3

Incorrect syntax near 'Labour'.: Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: Error in SQL statement Incorrect syntax near 'Labour'. ---> System.Data.OleDb.OleDbException: Incorrect syntax near 'Labour'.
at System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr)
at System.Data.OleDb.OleDbDataReader.NextResult()
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at Microsoft.Flow.RPA.Desktop.Modules.Database.Actions.DatabaseActions.ExecuteSQLStatement(Variant connectionString, Variant sqlConnectionVariable, Variant sqlCommand, Variant& result, Int32 timeout, Int32 getConnection)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.Database.Actions.ExecuteSqlStatement.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)


Flow Detail:

NiyatiNautiyal_1-1695779520151.png

NiyatiNautiyal_2-1695779566358.png

 

 

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @NiyatiNautiyal 

     

    Could you try this sql query instead ?

     

    INSERT INTO [dbo].[WebADI_File_Data]
    ([Id]
    ,[Power_Automate_Log_Id]
    ,[Upl]
    ,[Payment_Method]
    ,[Customer_Taxpayer_ID]
    ,[Legal_Entity]
    ,[Supplier_Number]
    ,[Payment_Terms]
    ,[Supplier_Site_Name]
    ,[PO_Number]
    ,[Quantity_Invoiced]
    ,[Invoice_Number]
    ,[Invoice_Comments]
    ,[Invoice_Description]
    ,[Invoice_Date]
    ,[Invoice_Total]
    ,[Line_Number]
    ,[Line_Description]
    ,[Line_Amount]
    ,[Tax_Code]
    ,[Project_Number]
    ,[Task_Number]
    ,[Expenditure_Type]
    ,[Expenditure_Item_Date]
    ,[GL_Account]
    ,[Expenditure_Organization]
    ,[Code_Of_Account]
    ,[Messages]
    ,[IsUploaded])
    VALUES
    (NEWID(),'F8CE65AF-1906-40C8-B0E4-AB7A9BD625B9','','','',80054,173661,'Pay When Paid','PO BOX 820','',%Quantity_Invoice[Index]%,%InvoiceNumber[Index]%,'','','',%Invoice_Total[Index]%,'',"%LineDescription[Index]%",%Invoice_Total[Index]%,'No Tax',%Project_Number[Index]%,'','9232-Subcontract(Construction)','7/25/2023','','800544103800570901 USA - HOUSTON','','',0)

     

     

    Hope the below information helps you as well: 

    https://learn.microsoft.com/en-us/power-automate/desktop-flows/how-to/troubleshoot-sql-queries

     

     

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The description is a string, and as such, it needs to be encapsulated within single quotes. Use '%LineDescription[Index]%' and it should work fine.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • NiyatiNautiyal Profile Picture
    9 on at

    Thanks @Agnius this fixed the problem

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 426

#2
11manish Profile Picture

11manish 308 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 159

Last 30 days Overall leaderboard