10

Microsoft SQL Server で更新クエリを実行すると、このエラーが発生します

equal to 操作で、"SQL_Latin1_General_CP1_CI_AS" と "SQL_Latin1_General_CP1_CI_AI" の間の照合の競合を解決できません。

クエリは、更新中のテーブルと内部結合を行う一時テーブルの2つのテーブルのみを使用します。どちらのテーブルも照合を指定しておらず、両方とも同じデータベース上にあります。つまり、同じ照合を持つ必要があるためです。データベースのデフォルトになる

照合を見ると、唯一の違いは最後の文字です。最後の部分について私が理解しているのは、CIがCase Insensitiveの略であることだけです。AI は Auto Increment の略だと思いますが、AS の略はわかりません

4

1 に答える 1

21

AI はアクセント インセンシティブを表します (つまり、cafe = café かどうかを判断します)。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  

例の出力:

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

于 2013-03-19T23:26:43.280 に答える