我的数据库中有一个 View ,有人用一个表中的 * 定义了该 View 。我刚刚向该表添加了一个新列,我希望 View 反射(reflect)新列。除了重新执行 View 创建脚本之外,还有其他方法重建 View 吗?我正在寻找类似于 sp_recompile 如何重新编译存储过程的东西(或者更准确地标记它以在下次调用时进行编译)。
更新:从长远来看,我尝试在 View 上调用 sp_recompile,虽然调用有效,但它没有重建 View 。
更新 2:我希望能够通过脚本执行此操作。因此,将列添加到表中的脚本也可以更新 View 。正如我所说,类似于 sp_recompile 的东西。
最佳答案
我相信您正在寻找的是
sp_refreshview [ @viewname = ] 'viewname'
Updates the metadata for the specified non-schema-bound view. Persistent metadata for a view can become outdated because of changes to the underlying objects upon which the view depends.
关于sql - 如何在 SQL Server 2008 中重建 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1557515/