Pass null value to execute sql query action in Logic Apps returns error

Kazi 1 Reputation point

I created a test action to make it clear what is my problem, of course my original logic app is much more complicated. The execute sql query action below returns the following error. Imo this is a SQL connector bug, because it should convert json null value to corresponding DBNull value (see this for example:

Is it possible to fix this bug?

The error message:

  "error": {  
    "code": 502,  
    "source": "",  
    "clientRequestId": "e7b89909-3d96-46f2-83a6-695523e7b1a5",  
    "message": "BadGateway",  
    "innerError": {  
      "status": 502,  
      "message": "The parameterized query '(@Param2 nvarchar(4000))select @Param2' expects the parameter '@Param2', which was not supplied.\r\nclientRequestId: e7b89909-3d96-46f2-83a6-695523e7b1a5",  
      "error": {  
        "message": "The parameterized query '(@Param2 nvarchar(4000))select @Param2' expects the parameter '@Param2', which was not supplied."  
      "source": ""  

The execute sql query action:

"TestDBNullAction": {  
    "inputs": {  
        "body": {  
            "actualParameters": {  
                "Param2": null  
            "formalParameters": {  
                "Param2": "int"  
            "query": "select @Param2"  
        "host": {  
            "connection": {  
                "name": "@parameters('$connections')['sql']['connectionId']"  
        "method": "post",  
        "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/query/sql"  
    "runAfter": {},  
    "type": "ApiConnection"  


Azure SQL Database
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,114 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,021 Reputation points

    I've sent your feedback on to the product team. You can also post on User Voice for people to vote on.

    I do understand it's not the ideal solution for you, but for now the best way to handle this case will be to chain in a Function that can handle the coalesce operation.

    1 person found this answer helpful.

  2. Sekhar_o, Chandra 1 Reputation point

    Any update on this fix yet?

    0 comments No comments