Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Symptoms

When the SQL plan has interleaved execution enabled and uses the OPTION (OPTIMIZE FOR) clause, the table-valued function (TVF) that uses a parameter passed in the same SQL statement gives incorrect results on the first run.

Resolution

This problem is fixed in the following cumulative update for SQL Server:

Cumulative Update 19 for SQL Server 2019

Note Here is an example of not using interleaved execution after you install this cumulative update:

DECLARE @start smalldatetime
SELECT count(*) FROM dbo.GetData(@start)
OPTION (OPTIMIZE FOR (@start = '2022-05-23T06:00:00'))

CREATE FUNCTION [dbo].[GetData]
(
  @start datetime
)
RETURNS TABLE AS RETURN
SELECT t.id FROM dbo.TestTable t
WHERE t.testdate >= @start
GO

CREATE TABLE [dbo].[TestTable](
       [id] [int] IDENTITY(1,1) NOT NULL,
       [testdate] [datetime] NULL
) ON [PRIMARY]
GO

Each new cumulative update for SQL Server contains all the hotfixes and security fixes that were in the previous build. We recommend that you install the latest build for your version of SQL Server:

Latest cumulative update for SQL Server 2019

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

References

Learn about the terminology that Microsoft uses to describe software updates.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×