KB3030619-修正:當您查詢 SQL Server 2014 中的 DATE 資料行時,傳回不正確的資料

Work anywhere from any device with Microsoft 365

Upgrade to Microsoft 365 to work anywhere with the latest features and updates.

Upgrade now


假設您有包含 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?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.