Error in procedure "Must declare the scalar variable"

2

When I run the following Procedure, SQLServer gives the error:

  

error Must declare the variable scalar "@VDIAPARALISADO".

Procedure:

BEGIN
SELECT @VDIAPARALISADO = COUNT(F.DATA)
FROM ED_FERIADO F
WHERE F.EDEMPRESA_ID = @PEDEMPRESA_ID
    AND F.GMUNICIPIO_ID = @PGMUNICIPIO_ID
    AND F.SECRETARIA_ID = @PSECRETARIA_ID
    AND F.ANO = @PANO
    AND F.TIPO IN ('6')
    AND F.DATA BETWEEN @DT_INICIO
        AND @DT_FIM
    AND F.DATA NOT IN (
        SELECT C.DATA
        FROM ED_CALENDAR C
        WHERE F.EDEMPRESA_ID = @PEDEMPRESA_ID
            AND F.GMUNICIPIO_ID = @PGMUNICIPIO_ID
            AND F.SECRETARIA_ID = @PSECRETARIA_ID
            AND F.ANO = @PANO
            AND F.DATA BETWEEN @DT_INICIO
                AND @DT_FIM
            AND C.TIPO_CALEN = @VTIPO_CALENDARIO
        )

            END
    
asked by anonymous 28.10.2014 / 12:57

3 answers

1

Missed add at first

DECLARE @VDIAPARALISADO INT
    
28.10.2014 / 13:03
0

You are trying to pass a recordset to a single variable. The variable @VIAPARIALISADO expects a Scalar value, that is, a single value.

    
04.06.2016 / 22:58
-1
DECLARE @VARIAVEL TIPO(TAM)
SET @VARIAVEL = VALOR (SE ELA FOR RECEBER UM VALOR)
    
30.06.2016 / 23:13