我有两个名字Georg Reisse Bauunternehmung和GeorgReißeBauunternehmung,需要将两者都插入一张桌子。我正在使用group by来消除新表中的重复行。由于ß被转换为ss我只看到一个名字,ß被转换为?。关于如何将这两个名字都用于一个的任何想法?还有一个ss插在桌子上?
初始表数据:
3449839 Georg Reisse Bauunternehmung以前称为
3449839GeorgReißeBauunternehmung以前称为
从查询
返回的数据1 NULL NULL Georg Rei?e Bauunternehmung 2017-01-18 09:46:22.997以前称为
查询:
SELECT
1 AS Enhancement_id,
CASE
When EntityName is null and not (Surname is null or Surname = '') and (MiddleName is null or MiddleName = '') Then Cast(FirstName as varchar(max)) collate SQL_Latin1_General_Cp1251_CS_AS
When EntityName is null and not (Surname is null or Surname = '') Then Cast(FirstName as varchar(max)) + ' ' + Cast(MiddleName as varchar(max)) collate SQL_Latin1_General_Cp1251_CS_AS
Else null
END AS FirstName,
CASE
When EntityName is null and not (Surname is null or Surname = '') Then Cast(Surname AS varchar(max)) collate SQL_Latin1_General_Cp1251_CS_AS
When EntityName is null and (Surname is null or Surname = '') Then Cast(FirstName AS varchar(max)) collate SQL_Latin1_General_Cp1251_CS_AS
Else null
END AS LastName,
CASE
When not EntityName is null Then Cast(EntityName AS varchar(max)) collate SQL_Latin1_General_Cp1251_CS_AS
Else null
END AS OtherName,
GETDATE() AS SourceDate,
NameType
FROM
[dbo].[Name]
WHERE
NameType <> 'Spelling Variation'
GROUP By
EntityID, EntityName, FirstName, Surname, MiddleName, NameType
ORDER BY OtherName