As described in the title, MSSQL is returning different results for the following two queries that I expect to return the same output:
Query 1:
DECLARE @year INT = 2024
DECLARE @month INT = 7
SELECT *
FROM udf_a(@year, @month)
Output:
Msg 8134, Level 16, State 1, Line 3
Divide by zero error encountered.
Warning: Null value is eliminated by an aggregate or other SET operation.
Total execution time: 00:00:06.520
Query 2:
SELECT *
FROM udf_a(2024, 7)
Output:
The resultset containing my expected data
udf_a
is a table-valued user-defined function that calls udf_b
another table-valued user-defined function within its body. udf_b
has the same parameters as udf_a
. I.e. the value of @year
and @month
is forwarded to udf_b
. But I believe this is irrelevant as I am passing the same parameter in the queries above and expect the same output.
The MSSQL version is: Microsoft SQL Azure (RTM) – 12.0.2000.8 Jun 3 2024 16:19:04 Copyright (C) 2022 Microsoft Corporation
I am running this in Azure Data Studio v1.48.1