Adu
Adu

Reputation: 381

String comparison

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?

Upvotes: 4

Views: 358

Answers (4)

Vasantham
Vasantham

Reputation: 1

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.

Upvotes: 0

Himadri
Himadri

Reputation: 8876

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'

Upvotes: 1

Arto Uusikangas
Arto Uusikangas

Reputation: 1909

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

Upvotes: 4

user114600
user114600

Reputation:

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

E.g. COLLATE Latin1_General_CI_AS

Upvotes: 2

Related Questions