We couldn’t sign you in
Select the account you want to use.

狀況

您有下列的情況皆成立的 SQL Server 資料庫中的資料表︰

  • 此資料表包含 Unicode 資料行。例如,資料表會有一個nchar(5)資料行。

  • Unicode 資料行的定序是"Latin1_General_BIN"。

  • 相同的 Unicode 資料行是索引的一部分。

不過,對此資料表所執行的 T SQL 陳述式可能會傳回不正確的結果。當下列情況成立時,就會發生這個問題︰

  • T SQL 陳述式包含"IN"或"或者"定義為相同的 Unicode 資料行的子句。

  • T SQL 陳述式包含 「 自動分頁] 類型轉換為另一個二進位定序的 Unicode 資料行。


查詢範例︰

CREATE TABLE [dbo].[Table_1]( [Col1] [smallint] NOT NULL,
[Col2] [nchar](5) ,
[Col3] [nchar](5) COLLATE Latin1_General_BIN NOT NULL, -- Col3 , a Unicode Column with “Latin1_General_BIN” collation
CONSTRAINT [PK__Table_1] PRIMARY KEY CLUSTERED -- Primary Key on all the 3 columns
(
[Col1] ASC,
[Col2] ASC,
[Col3] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


select * from Table_1 where Col1 = 1 and Col2 = '1' and Col3 collate Chinese_PRC_BIN IN (N'1' ,N'2') -- This statement using “IN” and “collate” might give incorrect results.
go


select * from Table_1 where Col1 = 1 and Col2 = '1' and (Col3 collate Chinese_PRC_BIN = N'1' or Col3 collate Chinese_PRC_BIN = N'2') -- This statement using “OR” and “collate” might give incorrect results.
go

狀態

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!

×