By having a table with thousands of Villages of course there are duplicates. In order to use them as mapping table it's necessary to mark them accordingly.
Table looks as follows;
| id | country | name | notUnique |
|---|---|---|---|
| 1234567 | Peru | Arenal | null |
| 1234568 | Mexico | Arenal | null |
| 1234569 | Honduras | Arenal | null |
| 1234570 | USA | Pasadena | null |
| 1234571 | Canada | Pasadena | null |
| 1234572 | Philippines | Pasadeña | null |
| 1234573 | Poland | Susk Nowy | null |
now I use my code snippet to fill out the not Unique:
-- generate RowSum:
update
Mapping.dbo.OsmGlobal
set
notUnique = 1
from
Mapping.dbo.OsmGlobal osm
join (
SELECT [name], COUNT([name]) RowSum
FROM Mapping.dbo.OsmGlobal osm
Group by [name]
) cnt
on osm.[name] = cnt.[name]
where cnt.RowSum > 1
go
obviously it results in result bellow, as there is no case insensitivity;
| id | country | name | notUnique |
|---|---|---|---|
| 1234567 | Peru | Arenal | 1 |
| 1234568 | Mexico | Arenal | 1 |
| 1234569 | Honduras | Arenal | 1 |
| 1234570 | USA | Pasadena | 1 |
| 1234571 | Canada | Pasadena | 1 |
| 1234572 | Philippines | Pasadeña | null |
| 1234573 | Poland | Susk Nowy | null |
To include 'Pasadeña' in my result groups of the 'Pasadena' I tried to add a collate Latin1_General_CI_AI. That is the point where I fail. Any help is highly welcome.