4

When comparing two strings how to avoid checking if a string is of different case in MS SQL 2000

Example:

String1 = Anish
String2 = anish

When comparing Anish = anish the result will be "the strings are not equal". How we compare these strings in that way?

4 Answers 4

4

Here is some information about case sensitivity. The thing that i can see is that the problem is how the server is installed.

Case sensitive search

2

Change the collation of the strings to some form of CI (case insensitive).

E.g. COLLATE Latin1_General_CI_AS

1

Try the following queries seperately in Northwind database:

SELECT *  FROM dbo.Customers  WHERE Country COLLATE SQL_Latin1_General_CP1_CS_AS  ='Germany'

SELECT *  FROM dbo.Customers  WHERE Country COLLATE SQL_Latin1_General_CP1_CS_AS  ='geRmany'
0

String Comparison in java is used to compare two different strings. We can compare string irrespective of case(upper case/ lower case). Consider str1="HELLO WORLD"; str2="hello world"; If we want to compare these to strings, there are two ways: String compareTo (String). String compareToIgnoreCase(String). Comparing String: str1 compareTo (str2); This statement will produce false as the output because java is case sensitive language. You can also compare the string irrespective of their case using the statement: str1 compareToIgnoreCase (str2); This will produce the output true because it will check only the character that stored in str1 and str2 without worrying about the case.

1
  • While your answer might be correct, it doesn't answer the OP's question, since it's related to string comparison in Sql Server. There's no reference to Java anywhere.
    – Luís Cruz
    Jun 9, 2015 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.