2017-03-31 49 views
0

有Unicode字符[¹] - 標之一(拉丁語1補充塊):SQL喜歡到不同的字符匹配

SELECT NCHAR(0x00b9) --returns ¹ 

但是,試圖找出是,在列中存在的符號下一個查詢返回行其中包含一個數字(0x0031):

SELECT [Name] FROM [Company] WHERE [Name] like '%'+nchar(0x00b9)+'%' 

更新:我使用MSSQL

回答

1

這是因爲你的數據庫有一個案例INsens itive整理:

SELECT DATABASEPROPERTYEX (DB_NAME(DB_ID()), 'COLLATION') -- = Latin1_General_CI_AS 

SELECT [Name] AS [WHERE_Collation caseINsensitive] 
FROM (VALUES ('¹') 
       , ('1')) AS Company (Name) 
WHERE [Name] LIKE '%'+nchar(0x00b9)+'%' 
; 

結果:

WHERE_Collat​​ion CASEINSENSITIVE

¹

SELECT [Name] AS [Collation caseSensitive] 
FROM (VALUES ('¹') 
       , ('1')) AS Company (Name) 
WHERE [Name] LIKE '%'+nchar(0x00b9)+'%' COLLATE Latin1_General_CS_AS 
; 

結果

WHERE_Collat​​i on case敏感

¹

+0

感謝您的回答 –