0
I have the following situation, I need to update several fields based on the return of a sub-query that returns a main code. This subconsultation is done with Join in two tables to obtain the code. When performing, I have the following error:
Message 512, Level 16, Status 1, Line 24 The subconsultation returned more than 1 value. This is not allowed when the subconsulta follows =, != , <, <= , >, >= or when it is used as an expression.
This is the consultation:
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 '
)
)
That’s right, I need to compare multiple returns, the ones in the sub-colony and update them. This database I’m working on is confusing, it generates the code in different tables and as it is a lot of data I thought to take the return of the sub-concession and go updating.
– Ronaldo Lopes
Already solved, just change the instruction from = to in in the first query.
– Ronaldo Lopes
mark as answered, to help other people.
– Peter Parker