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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anne-MarijnV
Frequent Visitor

Alter view on lakehouse SQL endpoint not working

At my company old sales orders are deleted from the source system after 2 years because they are no longer needed there.

To keep the data available for reporting, I've created a pipeline that will automatically extract the sales order information and store it in a lakehouse table at the end of the year.

So I currently have a lakehouse with tables: Sales Order History 2018-2023.

For reporting I have 1 generic Sales Order History view that combines data from all these tables.

 

Because I'm lazy and don't want to update the view manually every year, I have made a stored procedure that will alter the view's select statement 
(something like this)

 

 

DECLARE @sql NVARCHAR(MAX);

    SELECT @sql = STRING_AGG('SELECT * FROM ' + QUOTENAME(TABLE_NAME), ' UNION ALL ')
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_NAME LIKE 'Sales Order History%';

    SET @sql = 'CREATE OR ALTER VIEW AllHistory AS ' + @sql;

    EXEC sp_executesql @sql;

 

 

 

Whenever I run the stored procedure, I don't get any errors, but the view is not updated either.

Am I doing something wrong? Is this a fabric bug?

1 ACCEPTED SOLUTION
Anne-MarijnV
Frequent Visitor

deleting the lakehouse and recreating it did the trick. must've been some kind of bug

View solution in original post

3 REPLIES 3
Anne-MarijnV
Frequent Visitor

deleting the lakehouse and recreating it did the trick. must've been some kind of bug

v-hashadapu
Community Support
Community Support

Hi @Anne-MarijnV , Thank you for reaching out to the Microsoft Community Forum.

Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.

suparnababu8
Super User
Super User

Hello @Anne-MarijnV 

 

I'm not sure why its working. SQL Server saves information about views for quick access. However, if the tables used by the view are changed, the view's information might not update automatically. To fix this, you can try the sp_refreshview command to update the view's information so it matches the updated tables. At some cases, dynamic SQL might not execute as expected. 

 

If you need more info please visit below urls. It might helps you

Solved: Re: SQL Query / View not loading - Microsoft Fabric Community

Fix SQL Analytics Endpoint Sync Issues in Microsoft Fabric – Data Not Showing? Here's the Solution! ...

Lakehouse T-SQL Endpoint syncing issues (force update fix) · Learn Microsoft Fabric

 

Thank you!

 

 

 

 

Helpful resources

Announcements
Fabric July 2025 Monthly Update Carousel

Fabric Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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