Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at the 2025 Microsoft Fabric Community Conference. March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for $400 discount. Register now

Reply
ipkus
Regular Visitor

How to run Multiple SQL commands in Fabric Pipeline

We are executing a pipeline that bring data from On Prem.

 

The steps require to execute the following steps in 1 session

1 ) Run SP which populates a global temp table

2)  Access data from the temp table and populate that in Lakehouse.

NOTE : We can not run these two SQL seperately because it will run via seperate session and temp table will not be accesible. 

 

example: 

call sp( param1, param2 );

select * from global_temp_table1;

 

If any of you have implemented this in Fabric pipelines, do share your thoughts.

1 ACCEPTED SOLUTION
FabianSchut
Super User
Super User

Hi,

A Table-valued UDF may work better than a Stored Procedure in this case. You can query the results immediately without using a temporary table. You can run just one SQL query then. I'm not sure whether you are able to modify the source to change the stored procedure to a UDF, but here's an example of a UDF (from https://learn.microsoft.com/en-us/answers/questions/1291176/how-to-call-stored-procedure-and-stored-...)
CREATE FUNCTION CustomersByRegion
(
@RegionID int
)
RETURNS TABLE
AS
RETURN
SELECT *
FROM customers
WHERE RegionID = @RegionID
GO

View solution in original post

1 REPLY 1
FabianSchut
Super User
Super User

Hi,

A Table-valued UDF may work better than a Stored Procedure in this case. You can query the results immediately without using a temporary table. You can run just one SQL query then. I'm not sure whether you are able to modify the source to change the stored procedure to a UDF, but here's an example of a UDF (from https://learn.microsoft.com/en-us/answers/questions/1291176/how-to-call-stored-procedure-and-stored-...)
CREATE FUNCTION CustomersByRegion
(
@RegionID int
)
RETURNS TABLE
AS
RETURN
SELECT *
FROM customers
WHERE RegionID = @RegionID
GO

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebFBC_Carousel

Fabric Monthly Update - February 2025

Check out the February 2025 Fabric update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.