我正在使用 SQL Server Management Studio 2008。
我想从一个 View 中删除一条记录,该 View 在所有列的记录中显示空值。
我不知道,我从哪个表中得到这条空记录。
我检查了所有为 View 连接的表,但没有一个表包含空记录。
谁能帮我从我的 View 和所有相关表中删除这条空记录..?
因为我在许多其他页面中使用此 View ,它会在每个页面中产生空值错误。
当我尝试从 View 中删除这条记录时,它显示如下错误
"Msg 4405, Level 16, State 1, Line 1
View or function 'viewGetProgressOverview' is not updatable because the modification affects multiple base tables."
最佳答案
If you have created a View in SQL which is based on a single table – the DML operations you perform on the view are automatically propagated to the base table.
However, when you have joined multiple tables to create a view you will run into below error if you execute a DML statement against the view:
Msg 4405, Level 16, State 1, Line 1
View or function 'ViewName' is not updatable because the modification affects
multiple base tables.
Update join views规则如下:
Any INSERT, UPDATE, or DELETE operation on a join view can modify only one underlying base table at a time.
UPDATE Rule
All updatable columns of a join view must map to columns of a key-preserved table. See "Key-Preserved Tables" for a discussion of key-preserved tables. If the view is defined with the WITH CHECK OPTION clause, then all join columns and all columns of repeated tables are non-updatable.
DELETE Rule
Rows from a join view can be deleted as long as there is exactly one key-preserved table in the join. If the view is defined with the WITH CHECK OPTION clause and the key preserved table is repeated, then the rows cannot be deleted from the view.
INSERT Rule
An INSERT statement must not explicitly or implicitly refer to the columns of a nonkey preserved table. If the join view is defined with the WITH CHECK OPTION clause, INSERT statements are not permitted.
引用:-
关于sql-server-2008 - 从 View 及其所有相关表中删除记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14030457/