Operational Defect Database

BugZero found this defect 459 days ago.

Microsoft SQL Server | 2046472

KB5022920 - FIX: Table-valued function that uses a parameter and the OPTION (OPTIMIZE FOR) clause gives incorrect results on the first run - Microsoft Support

Last update date:

2/16/2023

Affected products:

SQL Server 2019 on Linux

SQL Server 2019 on Windows

Affected releases:

build lower than 15.0.4298.1

Fixed releases:

15.0.4298.1

Description:

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 About cumulative updates for SQL Server 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.

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Unavailable

Learn More

Search:

...