刷新所有相关的视图

GO  
SELECT DISTINCT 'EXEC sp_refreshview ''' + name + ''''   
FROM sys.objects AS so   
INNER JOIN sys.sql_expression_dependencies AS sed   
    ON so.object_id = sed.referencing_id   
WHERE so.type = 'V' AND sed.referenced_id = OBJECT_ID('dbo.table');  

表新增字段后会,导致视图字段对不上

使用 

sp_refreshview 进行刷新视图
posted @ 2021-11-24 19:35  _York  阅读(37)  评论(0编辑  收藏  举报