症状

假设你有一个包含 DATE 数据类型列的表,并且已在 Microsoft SQL Server 2014 中为此表实现了成簇列存储索引(CCSI)。 尝试使用 日期 数据类型作为限定符查询表时,可能会返回不正确的数据。例如:create table tab2(c1 int, c2 date, c3 varchar(10)) CREATE CLUSTERED COLUMNSTORE INDEX [CCI_tab2] ON [tab2] WITH (DROP_EXISTING = OFF)GO select *FROM tab2 S -- Table with clustered columnstore indexWHERE S.c2 = @date -- variable of Date datatype

解决方案

服务包信息

若要解决此问题,请获取 SQL Server 2014 的 Service Pack 1。

有关 SQL Server 2014 Service Pack 1 (SP1)的详细信息,请参阅 在 SQL server 2014 Service Pack 1 中修复的 bug

累积更新信息

此问题首先在 SQL Server 的以下累积更新中修复。

SQL Server 的每个新的累积更新均包含以前的累积更新中包含的所有修补程序和所有安全修补程序。 查看 SQL Server 的最新累积更新:

更多信息

使用以下代码再现此问题:create table tab1(c1 int, c2 date) insert into tab1values (1 , '2000-01-01') CREATE NONCLUSTERED INDEX [idxtab1c2] ON tab1( c2 ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) create table tab2(c1 int, c2 date, c3 varchar(10)) insert into tab2values (1, '2000-01-01', 'test') CREATE CLUSTERED COLUMNSTORE INDEX [CCI_tab2] ON [tab2] WITH (DROP_EXISTING = OFF)GO create table t([runId] int not null, [scalingFactor] float not null) -- REPRO QUERY. Below batch is expected to return a row but we don’t get ittruncate table tDECLARE @date DATE, @numDates INT INSERT INTO t VALUES(1, 1)DECLARE @date DATE, @numDates INTSELECT @date = max(R.c2) , @numDates = COUNT(distinct R.c2)FROM tab1 R INNER JOIN t D ON R.c1 = D.runId select *FROM tab2 S -- CCIWHERE S.c2 = @date

状态

Microsoft 已确认这是在“适用范围”部分中列出的 Microsoft 产品存在的问题。

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?

Thank you for your feedback!

×