-1
Hello, I’m with the following query to perform in a database but locked in a situation, below follows the query, the error message and then the explanation.
Excerpt from the Code
USE BDTESTE
GO
UPDATE NotaFiscalItens SET CODIGOPRODUTO =
(SELECT B.CODIGO FROM EstoqueMercadorias as B
WHERE
CAST(B.REFERENCIACLIENTE as INTEGER) = CAST(CODIGOPRODUTO as INTEGER)
AND B.EMPRESA = 1)
WHERE
EMPRESA = 22
AND SERIE = 2
AND OPERACAO = 133
AND DATA BETWEEN convert(smalldatetime,'01/06/2020',103) AND convert(smalldatetime,'30/06/2020',103)
GO
Error
Message 207, Level 16, Status 1, Line 13
Invalid DATE column name.
Message 207, Level 16, Status 1, Line 13
Invalid DATE column name.
Explanation
In the second WHERE where it reads:
"AND DATA BETWEEN convert(smalldatetime,'01/06/2020',103) AND convert(smalldatetime,'30/06/2020',103)"
the field DATE it comes from another table called NOTAFISCAL, and I’ve tried everything that is way researched on the internet, fit a JOIN with that table NOTAFISCAL in that query for me to be able to respect this condition of the initial and final period of the issuance of the notes to be updated the commodity code of the issued notes because they come from an integration with other software and I need to make this update which is practically a FROM/TO, with this the stock balance will be correct.
I’m grateful if someone can help me.
Follow this example in English: [link] (https://stackoverflow.com/questions/1293330/how-can-i-do-an-update-statement-with-join-in-sql-server) . the objective will be to make the Join between the table invoice and invoice items
– Claudio Lopes