Ciao a tutti, secondo voi dove sbaglio?
Data questa procedura:
CREATE PROCEDURE [dbo].[esisteScadenzaDay]
@p1 int = 0, --giorno
@p2 int = 0, --mese
@p3 int = 0, --anno
@quanti int OUTPUT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
select @quanti = count(distinct id)
from tblScadenza
where idAnno = (select id from tblAnno where anno = @p3)
and idMese = (select id from tblMese where mese = @p2)
and idGiorno = (select id from tblGiorno where giorno = @p1)
END
se lancio questa query mi restituisce 0 (io mi sarei aspettato 1)
declare @quanti as integer
exec @quanti = dbo.esisteScadenzaDay 12, 12,2006, @quanti
print @quanti
se lancio la query della procedure in questo modo
declare @quanti as integer
select @quanti = count(distinct id)
from tblScadenza
where idAnno = (select id from tblAnno where anno = 2006)
and idMese = (select id from tblMese where mese = 12)
and idGiorno = (select id from tblGiorno where giorno = 12)
print @quanti
mi torna 1, proprio come mi aspettavo io.
Grazie