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
 General SQL Server Forums
 Script Library
 Comments on Case Sensitive Search

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-10-22 : 08:19:51
Geoff writes "Hey,
I was reading one of your posts on case sensitive SQL queries (http://www.4guysfromrolla.com/webtech/sqlguru/q022400-1.shtml), and I thought I just might throw in my $0.02. This solution to the original question is for the MS-SQL environment, I am not sure if it will work on any other DBs. You can convert the string value to a binary representation and compare the binary checksum values.



/*******************START CODE*****************/

--Declare test variables
DECLARE @Val1 VARCHAR(10),
@Val2 VARCHAR(10)


--Set test variables value
SET @Val1 = 'my value'
SET @Val2 = 'My Value'


--Compare Val1 & Val2
IF Binary_Checksum(@Val1) <> Binary_Checksum(@Val2)
--the two values do not match
PRINT '@val1 does not match @val2, this process worked'

/*******************END CODE*****************/




Hope this helps somebody!

Have a good one.


Geoff Mina
Software Engineer | DBA
IVR Inc., a Prosodie Company
www.ivrinc.com
www.prosodie.com
716.929.1300 x 233"
   

- Advertisement -