I'm running into an error when altering a table in an SQL server, the query is simply this:
ALTER TABLE t_OrderDetail DROP COLUMN [TotalCost];
GO
ALTER TABLE t_OrderDetail ADD TotalCost
AS (((t_OrderDetail.[ItemQuant] * t_Item.[ItemCost]) * 17.5) / 100);
I wanted to apply the formula to the column - it is taking the cost of the item, multiplying that by the quantity bought, then adding 17.5% VAT.
This is how the tables are set up: Relationship Diagram
The error reads:
Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "t_Item.ItemCost" could not be bound.
Any suggestions? I've looked around for duplicate threads but most of what I can find are based on SELECT statements rather than altering a column formula. Thanks in advance.