我正在尝试将以下内容输入到QuoteItem的UPDATE触发器中:
UPDATE QuoteItem
SET List = StyleItem.List, CostFactor = StyleItem.CostFactor, Cost = NULL
FROM dbo.fn_GetQuoteItemListPrice(QuoteItem.ItemId, QuoteItem.RoomId)
AS StyleItem
CROSS JOIN (QuoteItem JOIN INSERTED ON
QuoteItem.QuoteItemId = INSERTED.QuoteItemId)
WHERE (INSERTED.List IS NULL) AND (INSERTED.ItemId IS NOT NULL)
我得到了以下错误:
Msg 4104, Level 16, State 1, Procedure QuoteItem_UPDATE, Line 6
The multi-part identifier "QuoteItem.ItemId" could not be bound.
Msg 4104, Level 16, State 1, Procedure QuoteItem_UPDATE, Line 6
The multi-part identifier "QuoteItem.RoomId" could not be bound.
答案 0 :(得分:0)
UPDATE QuoteItem
SET List = StyleItem.List, CostFactor = StyleItem.CostFactor, Cost = NULL
FROM dbo.fn_GetQuoteItemListPrice(xx.ItemId, xx.RoomId)
AS StyleItem
CROSS JOIN (QuoteItem JOIN INSERTED ON
QuoteItem.QuoteItemId = INSERTED.QuoteItemId) xx
WHERE (INSERTED.List IS NULL) AND (INSERTED.ItemId IS NOT NULL)
尝试我上面做的更改,指定一个表别名xx并引用它而不是..
答案 1 :(得分:0)
Naomi Nosonovsky发现here的答案:
UPDATE QuoteItem
SET List = StyleItem.List, CostFactor = StyleItem.CostFactor, Cost = NULL
FROM QuoteItem JOIN INSERTED AS INSERTED ON QuoteItem.QuoteItemId =
INSERTED.QuoteItemId
CROSS APPLY dbo.fn_GetQuoteItemListPrice(QuoteItem.ItemId, QuoteItem.RoomId)
AS StyleItem
WHERE (INSERTED.List IS NULL) AND (INSERTED.ItemId IS NOT NULL)