The following only returns surnames that are one character long.
Can I add a further condition so that it only returns Latin alphabet characters i.e. A-Z (plus a-z)
SELECT Surname
FROM WHData.dbo.vw_DimUser
WHERE
LEN(Surname) =1
AND <extra condition required>
GROUP BY Surname
Wildcard matching
Edit after comment below:
Let’s test:
You can see that both
Aandaare only matched correctly when[a-Z]is used as the match pattern.SQL Fiddle for example.
This can be explained in the answer to this previous SO question. Basically, with
Latin1_General_CS_AS, SQL server will sort characters like:However, to steal from the question again, Books Online states:
So I guess it’s COLLATION dependent to some extent, so really a case of testing in any particular environment where something liken this is deployed.