This SQL code returns "a" instead of "asdfg":
CREATE FUNCTION [dbo].[GetPayload2] (@ID int) RETURNS VARCHAR(300) AS BEGIN IF @ID = 1 RETURN 'asdfg' RETURN '' END GO SELECT dbo.GetPayload2(1)
Reproduced on both 15.0.2000.5 and 15.0.2070.41. Works fine in SQL Server 2017. Workaround is to use WITH INLINE = OFF.
EDIT: If you agree it's a bug, vote here please: https://feedback.azure.com/forums/908035-sql-server/suggestions/39190126-sql-server-2019-scalar-functions-with-inline-are-b
EDIT 2: CU2 for MS SQL Server 2019 is solving this issue :-)