SQL_Latin1_General_CP1_CI_AS与SQL_Latin1_General_CP1_CI_AI之间的区别是什么

Mem*_*r-X 8 t-sql

我在Microsoft SQL Server中运行更新查询时收到此错误

无法在等于操作中解决"SQL_Latin1_General_CP1_CI_AS"和"SQL_Latin1_General_CP1_CI_AI"之间的排序规则冲突.

查询只使用2个表,它正在更新的表和一个内部连接的临时表,两个表都没有指定整理,并且它们都在同一个数据库上,这意味着它们应该具有相同的排序规则,因为它应该是数据库的默认权限

看看排序,唯一的区别是最后一个字符,我最后一部分理解的是CI代表Case Insensitive.如果我在黑暗中采取刺,我会认为AI代表自动增量,但我不知道AS代表什么

Joh*_*van 18

AI代表口音不敏感(即确定咖啡馆=咖啡馆).您可以使用collat​​e关键字转换一个(或两个)值的排序规则.
有关详细信息,请参阅链接:http://msdn.microsoft.com/en-us/library/aa258237(v = sql.80).aspx

示例:DBFiddle

--setup a couple of tables, populate them with the same words, only vary whether to accents are included
create table SomeWords (Word nvarchar(32) not null)
create table OtherWords (Word nvarchar(32) not null)

insert SomeWords (Word) values ('café'), ('store'), ('fiancé'), ('ampère'), ('cafétería'), ('fête'), ('jalapeño'), ('über'), ('zloty'), ('Zürich')
insert OtherWords (Word) values ('cafe'), ('store'), ('fiance'), ('ampere'), ('cafétería'), ('fete'), ('jalapeno'), ('uber'), ('zloty'), ('Zurich')

--now run a join between the two tables, showing what comes back when we use AS vs AI.
--NB: Since this could be run on a database of any collation I've used COLLATE on both sides of the equality operator
select sw.Word MainWord
, ow1.Word MatchAS
, ow2.Word MatchAI
from SomeWords sw
left outer join OtherWords ow1 on ow1.Word collate SQL_Latin1_General_CP1_CI_AS = sw.Word collate SQL_Latin1_General_CP1_CI_AS 
left outer join OtherWords ow2 on ow2.Word collate SQL_Latin1_General_CP1_CI_AI = sw.Word collate SQL_Latin1_General_CP1_CI_AI  
Run Code Online (Sandbox Code Playgroud)

示例的输出:

MainWord MatchAS MatchAI
café cafe
store store store
fiancé fiance
ampère ampere
caféteríacaféteríacafétería
fête fete
jalapeño jalapeno
über uber
zloty zloty zloty
Zürich Zurich