I have a really simple scalar function with the following code:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[GetNDate_YYYYMM]
(
@InputDate DATETIME
)
RETURNS INT
AS
BEGIN
DECLARE @RIS AS INT
SET @RIS=NULL
IF (@InputDate IS NOT NULL) SET @RIS=(YEAR(@InputDate)*100)+(MONTH(@InputDate))
USCITA:
RETURN @RIS
END
This function has worked for years in SQL 2012 but now I have migrated the function to SQL 2019 I get the following message:
Msg 107, Level 15, State 1, Procedure GetNDate_YYYYMM, Line 1 [Batch Start Line 0]
The column prefix 'DT0' does not match with a table name or alias name used in the query.
In reality if I run a select on this function from the SQL management studio (and not during a stored procedure, where I first noticed the problem) I get this message only on the first run and then it doesn't appear until I reconnect to the DB.
Thanks for the help, James