徵狀

假設您有包含 DATE 資料類型資料行的資料表,且您已在 Microsoft SQL Server 2014 的此資料表中實現聚集欄商店索引(CCSI)。 當您嘗試使用 DATE 資料類型做為限定詞來查詢資料表時,可能會傳回不正確的資料。例如: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

解決方案

Service pack 資訊

若要解決此問題,請取得 SQL Server 2014 的 Service Pack 1。

如需 SQL Server 2014 Service Pack 1 (SP1)的詳細資訊,請參閱 在 Sql server 2014 Service pack 1 中修正的錯誤

累積更新資訊

這個問題首先是在 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!

×