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

前端之家收集整理的这篇文章主要介绍了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.f2er.com/mssql/77730.html

猜你在找的MsSQL相关文章