I have the following situation, I need to perform an update on several fields based on the return of a subquery that returns a main code. This subquery is done with join in two tables to get the code. While doing this, I get the following error:
Message 512, Level 16, State 1, Line 24 The subquery returned more than 1 value. This is not allowed when the subquery follows a =,! =, & Lt ;, < =, & gt ;, > = or when it is used as an expression.
This is the query:
BEGIN TRANSACTION;
UPDATE Produto SET TpProduto = 'C' WHERE IdProduto = (
SELECT DISTINCT(p.IdProduto)
FROM dbo.Produto p
JOIN dbo.CodigoProduto cp ON cp.IdProduto = p.IdProduto
WHERE cp.CdChamada IN(
'3VT9200-4ED30 ',
'3VT9225-6AC00 ',
'5SX11207 ',
'6ES73921AJ000AA0 ',
'8910427 ',
'9676812 ',
'CON000280 '
)
)