Troubleshoot SQL queries

While developing desktop flows, you may encounter errors caused by deployed database actions that run queries on databases. If you can't identify the source of the issue through the displayed error messages, perform the following troubleshooting steps:

  1. Replace any single quote (') characters with double quotes (") or the other way around.

    For example, the following query produces an error because of the single quote at the end of the variable’s value.

    SELECT * FROM SALES WHERE VALUE = '%value%'; 
    

    To resolve this issue, replace the single quotes in the SQL statement with double-quotes.

    SELECT * FROM SALES WHERE VALUE = "%value%"; 
    
  2. Escape percentage signs (%) that don't indicate variables.

    Power Automate identifies percentage signs as characters that indicate variables. To use them as normal characters, escape them using an extra percentage sign.

    Note

    You can find more information about the percentage signs in Use variables and the % notation.

  3. Ensure that the same versions (32 bit or 64 bit) of database, database server, and Power Automate for desktop are installed on your desktop.

  4. Verify that the firewall or any other network security system isn't blocking the connection between Power Automate and the database.

  5. If you're using database actions to run queries on Excel files, ensure that you've applied the following practices:

    • The name of the Excel worksheet is used as a database name. Enclose the worksheet name in brackets ([]) and add a dollar sign ($) at the end, for example [Sheet1$].
    • The database columns are the headers of the Excel data table.
    SELECT * FROM [Sheet1$] WHERE Value = "%value%"; 
    

    Note

    You can find more information regarding running SQL queries on Excel in Run SQL queries on Excel files.