2

Let's say I want find a Stack Overflow user by location.

Note: In my case city location

I found the query, and here is the link.

In this query we can found user by location.

Example: I want the user from surat city.

If I write surat and run the query it gives the below result:

Enter image description here

But when I write the city name first letter Capital like Surat, see below image.

Enter image description here

Both results are true.

because the user which have write first letter Capital it show in Surat. and the user which have write first letter small it show in surat detail.

My question is:

Is there a query which displays the combination of these two results or ignore Small / Capital and give the result?

1 Answer 1

2

You need to indicate the collation to use for your LIKE statement, as I did in your forked query

Location like '%##Location##%' collate Latin1_General_100_CI_AI

The above collate tells Sql Server to compare the Location and the parameter case insensitive and accent insensitive. See the COLLATE clause.

Almost all fields in the database are defined as SQL_Latin1_General_CP1_CS_AS which is the reason you have different results when using upper or lower case characters.

In the above query the other result sets show the collation info from the server, databases and that specific column.

You must log in to answer this question.