2012-09-19 75 views
0

我正在準備一個新的數據庫服務器,我將從一個大的,現有的多語種數據庫(主要是英語/法語/西班牙語文本,很少來自其他語言的特殊字符,例如城市名稱)遷移數據。 我的問題是:它應該重音敏感嗎? 如果搜索沒有區別咖啡館和咖啡館,用戶會很高興。 但作爲一名DBA,我很擔心:我從來沒有見過一段時間內至少有一次數據庫沒有遭受糟糕的字符轉換。如果我選擇不區分重音,我將如何查詢數據庫並要求「給我所有標題包含特殊字符的書」? 如果我有辦法做到這一點,我會愉快地去重音不敏感。新數據庫:它應該重音敏感嗎?

回答

1

它應該取決於你的一般用法。

這並不妨礙你改變它特定的查詢

declare @t1 table (word nvarchar(50) collate Latin1_General_CI_AI) 
declare @t2 table (word nvarchar(50) collate Latin1_General_CI_AS) 

insert @t1 values ('cafe'),('restaurant'), ('café') 
insert @t2 select * from @t1 

select * from @t1 where word like 'cafe' 
select * from @t1 where word like 'cafe' collate Latin1_General_CI_AS 
select * from @t1 where word like 'café' 
select * from @t1 where word like 'café' collate Latin1_General_CI_AS 

select * from @t2 where word like 'cafe' 
select * from @t2 where word like 'cafe' collate Latin1_General_CI_AI 
select * from @t2 where word like 'café' 
select * from @t2 where word like 'café' collate Latin1_General_CI_AI 
1

You can change collation at select time:

with t as (
select 'ali' as w union 
select 'àli' as w 
) 
select * 
into #t 
from t; 

select * from #t 
where w collate Latin1_General_CS_AS_KS_WS like '%à%' 

w 
--- 
àli 


select * from #t 
where w collate Traditional_Spanish_ci_ai like '%à%' 

w 
--- 
ali 
àli