且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更新或插入视图或函数失败,因为它包含派生或常量字段

更新时间:2023-02-06 20:20:54

评论有点长.

我找不到关于这个主题的 2012 年文档,但是 SQL Server 2008 文档 非常清楚:

I cannot readily find the 2012 documentation on this subject, but the SQL Server 2008 documentation is quite clear:

当视图是一个视图时,该视图被认为是可更新的分区视图组合单个结果集的一组 SELECT 语句使用 UNION ALL 语句合二为一.每个 SELECT 语句引用一个 SQL Server 基表.

A view is considered an updatable partitioned view when the view is a set of SELECT statements whose individual result sets are combined into one using the UNION ALL statement. Each SELECT statement references one SQL Server base table.

您在 from 子句中有两个表,因此它不可更新.它是只读视图.我不知道这在 2012 年发生了变化.

You have two tables in the from clause, so it is not updatable. It is a read-only view. I am not aware that this was changed in 2012.