微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

tsql – SQL_Latin1_General_CP1_CI_AS和SQL_Latin1_General_CP1_CI_AI之间有什么区别

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

Cannot resolve the collation conflict between “sql_latin1_General_CP1_CI_AS” and “sql_latin1_General_CP1_CI_AI” in the equal to operation.

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

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

解决方法

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'),('fiance'),('ampere'),('fete'),('jalapeno'),('uber'),('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

示例的输出

MainWord MatchAS MatchAI咖啡馆咖啡馆商店商店未婚夫未婚夫安培安培caféteríacaféteríacaféteríafêtefetejalapeño墨西哥胡椒über优步兹罗提兹罗提兹罗提苏黎世苏黎世

原文地址:https://www.jb51.cc/mssql/77730.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐