Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to match the case of alphabets

Author  Topic 

azharrahi
Starting Member

44 Posts

Posted - 2006-08-22 : 05:50:48

I have a select query with 'Where' Clause on a varchar coloumn say C1.
Let C1 contains 'Abc'...and i pass 'abc' in where clause for selection on C1 and where clause is also applied on C1.

I want that 'Abc' is not equal to 'abc'.how can i do it in select query.

LazyDragon
Starting Member

30 Posts

Posted - 2006-08-22 : 06:14:17
http://vyaskn.tripod.com/case_sensitive_search_in_sql_server.htm

LazyDragon
T-SQL Programmer
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-22 : 06:56:55
If your collation already is CASE SENSITIVE, the two cases will be different.

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-22 : 07:03:33
Actually BINARY_CHECKSUM is not to prefer.

BINARY_CHECKSUM('aa') = BINARY_CHECKSUM('bQ') and there are many other cases where binary_checksum is not unique!

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

azharrahi
Starting Member

44 Posts

Posted - 2006-08-22 : 09:29:55
Well Thanks For all of you for giving attention to my problem. My problem is solved throught casting both values (ie Value in column and parameter value) into varbinary. The result returns false for " Where 'Abc' = 'abc' "

Azhar Rahi
Software Engineer
Eye4tech Pvt Ltd,Lahore
Pakistan
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-08-22 : 09:45:01
You can also use a specific (different) collation for the comparison. (i think this is covered in LazyDragon's link)

Where [C1] COLLATE SQL_Latin1_General_CP1_CS_AS = 'abc' COLLATE SQL_Latin1_General_CP1_CS_AS

Be One with the Optimizer
TG
Go to Top of Page

azharrahi
Starting Member

44 Posts

Posted - 2006-08-23 : 02:39:28
yes TG, this is covered in LazyDragon's Link.

Well my problem is solved through convarion both varchar Values into varbinary and then check it.

But can you tell me what is the most effiecient way between the two ie between "through

Conversion into varbinary" or "through Collate"

Azhar Rahi
Software Engineer
Eye4tech Pvt Ltd,Lahore
Pakistan
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-08-23 : 11:16:02
The best way to answer that question is to test it out both ways with your own data, table structures, indexes, etc.

My intuition tells me collate would be most effecient because it wouldn't involve converting the stored values. But why don't you test it yourself and tell us what the real answer is

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -