CREATE VIEW ProductCode WITH SCHEMABINDING AS SELECT ProdID, Cost, Qty, SUM(qty *cost) FROM Products

You have created a view that your users need to use update records in one of your tables. The code to create the view looks like this:

CREATE VIEW ProductCode WITH SCHEMABINDING AS SELECT ProdID, Cost, Qty, SUM(qty *cost) FROM Products

What do you need to change on this view to make it updateable?



Answer – Change the code to look like this:
CREATE VIEW ProductCost WITH SCHEMABINDING AS
SELECT ProdID, Cost, Qty FROM Products
 (Aggregate functions, such as SUM( ) and AVG( ), are not allowed in updateable views, so you have to remove SUM(qty * cost). Also note, ALLOWAGREGATES is not a valid option.)