33
Views
2
Comments
Solved
Is it possible to search with case sensitivity using Aggrigate?
Question

Hi,
For Nvarchar fields in UnicodeDB, in SQL Server, I think that if we don't specify 'N' in the search, we can't perform a case-sensitive search.

Is there a way to achieve this using Aggrigate?

Solution

Whether a string compare operation is case sensitive or not depends on the collation settings in the database. If you want to override the database collation, you can specify a specific collation after the name of the column. Of course, this only works in a SQL query, not in an aggregate. For example:

SELECT *
FROM {User}
WHERE {User}.[Username] COLLATE SQL_Latin1_General_CP1_CS_AS like 'k%'

only selects usernames starting with a lowercase 'k', while without the COLLATE, it also selects usernames with an uppercase 'K'.

Hi @Kilian Hekhuis,

Thank you for your helpful sharing!

Best regards ,
THOAN 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.