マッチング アルゴリズムを定義する必要があります。一致する単語をカウントする場合、出現順序に関係なく、次のようになります。
declare @t table(field varchar(200))
insert into @t values('United Kingdom - Mobile - O2')
declare @upload varchar(200) = ' United Kingdom - O2 Mobile noise'
-- Let's find matching words, no matter in what order they are!
declare @IgnoreChars varchar(50) = char(13)+char(10)+char(9)+'-.,'
select t.field,
MatchedWords = SUM(CASE WHEN m.WordFoundAt=0 THEN 0 ELSE 1 END),
TotalWords = COUNT(*)
from @t t
CROSS APPLY dbo.str_split(dbo.str_translate(@upload, @IgnoreChars, REPLICATE(' ', LEN(@IgnoreChars))), ' ') w
OUTER APPLY (SELECT WordFoundAt = CHARINDEX(w.id, t.field)) m
where w.id <> ''
group by t.field
結果:
field MatchedWords TotalWords
イギリス - モバイル - O2 4 5
関数 str_translate と str_split は組み込みではありませんが、添付ファイルが許可されていないため、ここに投稿する方法がわかりません。