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

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
sgeheeb
Resolver I
Resolver I

Fabic warehouse SP fails with Maximum stored procedure nesting level exceeded

Hi,

I am trying to merge data into a table in a Fabric warehouse.

Since MERGE is not supported yet, I am performing the merge in two steps: Update exising entries and Insert new entries (for this specific table, no delete is required).

We'll only have look at the update part, since this already causes the error by itself:

When i run this (simplified version) as a regular SQL-Statement, it works:

 

UPDATE DWH.Customer

  SET Name= SRC.Name

FROM DWH.Customer DST

  INNER JOIN Stage.Customer SRC

  ON DST.Company = SRC.Company

  AND DST.Code = SRC.Code;


This completes in about 5 seconds.

When I wrap the whole thing in a stored procedure, it runs for a while and then fails with:
"Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)."

Interstingly, the update works correctly, but the process keeps running for an additional 10 seconds before it fails.

Any ideas what causes this and how to fix it? I ran into something similar years ago in a customer project where they were using an ungodly logic based on hundereds of triggers. Then, the error made sense. But joining two tables should not cause this.

 

UPDATE:

I have an update on this. I tried the same approach for a different table (which has more columns and rows and addtional field on which I perform the join) and it works. Does this have something to do with the underlying delta structure (e.g. Fabric performing additional joins under the hood, over which I have little control)?

1 ACCEPTED SOLUTION

Hi, I tried you suggestions - to no avail unfortunately.

I ended up deleting the SP and re-creating it by deploying a bacpac from VS Code. This seems to have done the trick.

Thank you!

View solution in original post

4 REPLIES 4
v-nmadadi-msft
Community Support
Community Support

Hi @sgeheeb  ,
Thanks for reaching out to the Microsoft fabric community forum.

Currently there are no known issues related to stored procedure in Fabric Warehouse which may cause the error.
 I also tried to replicate your exact scenario and I have not faced the same error, perhaps it may be helpful to check if there are any mistakes with syntax other than that,

Check whether there are any triggers defined on the DWH.Customer table, as unintended recursion can occur from system generated or user defined triggers. You can inspect this by running the query:

SELECT *

FROM sys.triggers

WHERE parent_id = OBJECT_ID('DWH.Customer');
If any triggers are returned, review their logic carefully, and consider disabling them temporarily to determine whether they are contributing to the nesting level issue.

Additionally try creating a stored procedure with some other update query to check if the issue is specific to the merge query or related update query in general.

Please try these troubleshooting steps to find any particular root cause of the issue.

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you

Hi, I tried you suggestions - to no avail unfortunately.

I ended up deleting the SP and re-creating it by deploying a bacpac from VS Code. This seems to have done the trick.

Thank you!

Hi @sgeheeb ,

We really appreciate your efforts and for letting us know the update on the issue.
Please accept your reply as the solution so as to help other community members who may come across this post in the future.

Please continue using fabric community forum for your further assistance.
Thank you

Srisakthi
Continued Contributor
Continued Contributor

Helpful resources

Announcements
May FBC25 Carousel

Fabric Monthly Update - May 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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