次のテーブルがあるとします。
create table t_Item (
ItemID int not null identity(1,1) constraint PK_Item primary key,
Description varchar(256) not null,
Price decimal(10,2) not null
)
および次のビュー:
create view Item as
select ItemID
,Description
,Price
,1.09 Tax
,Price * 1.09 TaxedPrice
from t_Item
TaxedPrice
は派生列でありTax
、定数列です。
したがって、それらのいずれも挿入または更新できません。次の最初のクエリは成功しますが、他のクエリはエラーで失敗します。
insert into Item (Description, Price) values ('Test item', 14.00)
insert into Item (Description, Price, TaxedPrice) values ('Test item', 14.00, 15.26)
insert into Item (Description, Price, Tax) values ('Test item', 14.00, 1.09)
そして、返されたエラー メッセージは次のとおりです。
派生フィールドまたは定数フィールドが含まれているため、ビューまたは関数 'アイテム' の更新または挿入に失敗しました。
おそらくシステムビューを使用して、更新してはならないビュー列をリストする方法はありますか?