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 / Unable to Return Resul...
Power Automate
Answered

Unable to Return Result Set from On-Premise SQL Server Stored Procedure

(0) ShareShare
ReportReport
Posted on by 44

Can someone please help me understand why I'm not able to see a ResultSet from my Stored Procedure. I only return an Output.

Capture.JPGCapture2.JPG

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,923 Most Valuable Professional on at

    When you click on the "Click to Download" link in the output section what do you get?  is the screen blank or filled with JSON?  If its filled with JSON then you are getting a return value, but may need to Parse it using Parse JSON to gain access to the values.

  • Justinrr07 Profile Picture
    44 on at

    @Pstork1 I was able to return a result set once I provided a JSON sample with a smaller data set. I guess my original was too large. However, I'm still unable to return the fields from the resultset to powerapps. It's only returning two unknown columns "items" & "type".

    Capture (1).JPGCapture (2).JPGCapture (3).JPG

    If I try to parse and then use "Respond To Power Apps" step, I can only see "type" as a field and not my actual fields from my stored procedure:

    Capture (4).JPG

    here is my JSON schema:

    {
     "type": "object",
     "properties": {
     "ResultSets": {
     "type": "object",
     "properties": {
     "Table1": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "Id_TraineeSignedTask": {
     "type": "integer"
     },
     "Trainee_Id": {
     "type": "integer"
     },
     "Task_Id": {
     "type": "integer"
     },
     "TrainerAtTimeOfTraineeSignature": {
     "type": "string"
     },
     "CourseVersion_Id": {
     "type": "integer"
     },
     "Note": {
     "type": "string"
     },
     "Id_TrainerSignedTask": {
     "type": "integer"
     },
     "TraineeSignedTask_Id": {
     "type": "integer"
     },
     "TrainerSignatureTime": {
     "type": "string"
     },
     "TrainerName": {
     "type": "string"
     },
     "TaskStatus": {
     "type": "string"
     }
     },
     "required": [
     "Id_TraineeSignedTask",
     "Trainee_Id",
     "Task_Id",
     "TrainerAtTimeOfTraineeSignature",
     "CourseVersion_Id",
     "Note",
     "Id_TrainerSignedTask",
     "TraineeSignedTask_Id",
     "TrainerSignatureTime",
     "TrainerName",
     "TaskStatus"
     ]
     }
     }
     }
     },
     "OutputParameters": {
     "type": "object",
     "properties": {}
     }
     }
    }
  • Pstork1 Profile Picture
    68,923 Most Valuable Professional on at

    A couple of suggestions.

    1) You can use Data Select and Filter Array to remove unneeded rows and columns from your results to decrease the size of the result you want to return

    2) You can't use Respond to Power Apps to return a data set.  Respond to Power Apps can only return a single object with some properties.  You need to use HTTP response if you want to return a full array of data to be stored in a collection.  Your HTTP response action in your flow should be the last action in your flow.

    3) Based on your schema you are only returning a single object from SQL, not an array of data.  

  • Verified answer
    Justinrr07 Profile Picture
    44 on at

    Ok, after extensive testing and trial and error, I got it working. I guess I had to change the name of the SQL step to "Execute a SQL Query" even though its a Stored Procedure task.

    Capture.JPG

     

    Add an expression to the response task in the Body field:

    body('Execute_a_SQL_query').ResultSets.Table1

    Capture2.JPG

    and now it works fine. The only thin I was doing different in my previous attempts was the SQL task name was different. It still matched my Response expression but only once I changed it to "Execute a SQL Query" did it start working. Seems strange to me.

    I'm also disappointed by the limitations of this method i.e. can't return data type image and I can't return a time converted to an integer. After 4 days of trial and error, I'll take what I can get.

  • Pstork1 Profile Picture
    68,923 Most Valuable Professional on at

    Just to be clear.  You do not need to run this as Execute SQL Query.  You can run it as Execute Sql Stored Procedure.  Your previous screenshots show you processing the results set, not the results set Table.  I suspect that is where the problem lies.

  • Justinrr07 Profile Picture
    44 on at

    @Pstork1 

    Unfortunately I can not prove otherwise. I even created a new Flow to test. Everything is exactly the same except the SQL name. They both run fine in Flow. BUT in Power Apps, only one of them can be stored in a collection. I guess it's a Power Apps issue.

    Capture.JPG

    Capture4.JPG

     

  • Pstork1 Profile Picture
    68,923 Most Valuable Professional on at

     

     

    I would need to see your stored procedure to figure out why its not working for you, but I can show you several examples where I call a flow from a Power App, run a stored procedure, and return the results back to a collection in Power apps.  It does work.  I'm not sure why it won't work for you.  Here's just one example

    image.png

    image.png

  • Justinrr07 Profile Picture
    44 on at

    @Pstork1 thank you for the help. Here is my SPROC:

     

    ALTER PROCEDURE [dbo].[spSccSignedTasksByTraineeId] @TraineeId int
    AS
    SET NOCOUNT ON;
    SELECT [Id_TraineeSignedTask]
     ,[Trainee_Id]
     ,[Task_Id]
     ,[TrainerAtTimeOfTraineeSignature]
     ,[CourseVersion_Id]
     ,[Note]
     ,[Id_TrainerSignedTask]
     ,[TraineeSignedTask_Id]
     ,[TrainerSignatureTime]
     ,[TrainerName]
     ,[TaskStatus]
    FROM vSccSignedTasks
    WHERE Trainee_Id = @TraineeId
  • Pstork1 Profile Picture
    68,923 Most Valuable Professional on at

    What Data types are the SQL fields you are returning?  

  • Justinrr07 Profile Picture
    44 on at

    I crossed off the fields i'm not pullin into the SPROC, but this is the view I'm referencing:

    Capture.JPG

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 86 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 55

#3
Ellis Karim Profile Picture

Ellis Karim 53 Super User 2026 Season 1

Last 30 days Overall leaderboard