I’ve got two stored procedures:
SP1
CREATE PROCEDURE GetAge
@Birthday datetime,
@BirthDayAge INT OUTPUT
AS
SELECT @BirthDayAge = YEAR(GETDATE()-DATEPART(dy, @Birthday) + 1)-YEAR(@Birthday);
SP2
CREATE PROCEDURE AgeProc
@Age int
AS
DECLARE @BirthDayAge INT;
EXEC GetAge @Age, @BirthDayAge OUTPUT
SELECT ... FROM ... WHERE @BirthdayAge = @Age;
For some reason or other, no results are being returned in the second procedure when tested. Am I doing something wrong in either of the stored procedures?
you are comparing 2 variables.
Shouldnt one of this be a table column?
also, you are passing an integer to a datetime, that may cause issues