I need help to do the following expression does not exist:
set @DataMesAnt = CAST(CONVERT(CHAR(10), GETDATE(), 121) AS SMALLDATETIME)
IF NOT EXISTS(SELECT * FROM NfiCabV ncv JOIN NfiItmV niv
ON (
ncv.Nfi_Planta = niv.Nfi_Planta
AND ncv.Nfi_NotFis = niv.Nfi_NotFis
AND ncv.Nfi_Serie = niv.Nfi_Serie
)
WHERE ncv.Nfi_Planta in ('01','06')
AND ncv.Nfi_DatEmi = @DataMesAnt
AND ncv.Nfi_OriNfi = 'P'
AND ncv.Nfi_SitNfi IS NULL
AND ncv.Nfi_Serie IN ('U1', '1') )
BEGIN
set @DataMesAnt = CAST(CONVERT(CHAR(10), GETDATE()-1, 121) AS SMALLDATETIME)
END
can anyone help me?