UPDATE, SET, FROM with INNER JOIN and WHERE with multiple hits
Hej eksperter,Jeg har et problem med UPDATE, SET, FROM med flere tabeller INNER JOIN hvor WHERE giver mange hits:
SELECT funktionen fungerer og giver 9 hits med denne:
---
SELECT ItemInstance.ItemInstanceID, ItemInstance.Year, ItemInstance.Week, WarehouseConfiguration.WarehouseInitials
FROM ItemInstance
INNER JOIN Project ON ItemInstance.DestinationProjectID = Project.ProjectID
INNER JOIN WarehouseConfiguration ON Project.WarehouseID = WarehouseConfiguration.WarehouseID
WHERE (WarehouseConfiguration.WarehouseInitials = N'Z1') and (ItemInstance.Year = N'2009')
---
Jeg forsøgte med følgende UPDATE:
---
UPDATE ItemInstance
SET ItemInstance.Week = ItemInstance.Week + 1
FROM ItemInstance
INNER JOIN Project ON ItemInstance.DestinationProjectID = Project.ProjectID
INNER JOIN WarehouseConfiguration ON Project.WarehouseID = WarehouseConfiguration.WarehouseID
WHERE (WarehouseConfiguration.WarehouseInitials = N'Z1') and (ItemInstance.Year = N'2009')
---
og får denne fejl:
"Msg 512, Level 16, State 1, Procedure UpdateItemInstance, Line 21
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated."
Hvis jeg sætter WHERE til et direkte hit på 1 virker det fint.
Hvad kan jeg gøre?