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 / Using SQL Structured P...
Power Automate
Suggested Answer

Using SQL Structured Procedure performance.

(0) ShareShare
ReportReport
Posted on by 3,347
I have a structured procedure that works great in SQL SMSS.  The execution takes around 5 seconds.  When I invoke the procedure from powerapps, through a SQL structured procedure action, the run-time varies from 5s to several minutes.  Same data in and out.  The SQL server is VERY lightly loaded, in fact there may not be anyone at all using the sever when I'm invoking the procedure.  Why is there such a wide variance in performance?   
 
This procedure is quite simple.  It takes a long text string of numbers separated by a comma, creates a table from this, then joins with a view in SQL.  The resulting table is the desired result.  
[dbo].[FilterByPartNumbers]
    @PartNumbers NVARCHAR(MAX)
AS
BEGIN
    SET NOCOUNT ON;

    -- Create a temporary table for parsed part numbers
    CREATE TABLE #ParsedPartNumbers (
        PartNumber NVARCHAR(255) COLLATE Latin1_General_CI_AS_KS_WS NOT NULL PRIMARY KEY
    );

    -- Populate the temporary table
    INSERT INTO #ParsedPartNumbers (PartNumber)
    SELECT DISTINCT TRIM(value) COLLATE Latin1_General_CI_AS_KS_WS
    FROM STRING_SPLIT(@PartNumbers, ',');

    -- Select data directly from dbo.View_all_pdm_latest_pa
    SELECT 
        pp.PartNumber,
        v.*,
        CASE 
            WHEN v.PartNumber IS NULL THEN 1
            ELSE 0
        END AS Acc_Only
    FROM #ParsedPartNumbers pp
    LEFT JOIN dbo.View_all_pdm_latest_pa v
        ON pp.PartNumber = v.PartNumber COLLATE Latin1_General_CI_AS_KS_WS;

    -- Drop the temporary table
    DROP TABLE #ParsedPartNumbers;

    SET NOCOUNT OFF;
END;
Flow action:
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at
    Are you able to run an SQL trace to see what is taking that long for SQL server to respond.
     

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 308 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 171 Super User 2026 Season 2

#3
Haque Profile Picture

Haque 137 Super User 2026 Season 2

Last 30 days Overall leaderboard