I am executing a stored procedure inside another stored procedure.
I pass the parameters and when the value is not null, it works perfectly fine, but when the value generates as 0 rows, it gives me error.
Stored procedure:
declare @LDate datetime
declare @DateEntered datetime
insert into Table1 values(5,5)
EXEC @LDate = GetLDate @ID, @GID // other stored procedure inside the main stored procedure
// GetLDate is ("select Date1 from TableGetDate where @ID =4,@GID=5")
if(CAST(@LDate as datetime) < CAST(@DateEntered as datetime))
Select '-1'
else
SELECT '-2'
When in the C# code I call ExecuteScalar
, it returns null if @LDate
returns no date. If @LDate
returns a date then everything works perfectly fine.
How to solve this?