Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CHECK_SUM returns same value for diff. inputs

Status
Not open for further replies.

joxa83

Programmer
Nov 30, 2005
7
YU
I was performing some case sensitive comparsions and as one of options was to use check sum, anyway I conluded that CHECK_SUM and BINARY_CHECK sum functions return same value for different inputs.As far as I know those functions are like hash functions and CHECKSUM applied over any two lists of expressions returns the same value if the corresponding elements of the two lists have the same type and are equal when compared using the equals operator.
SELECT BINARY_CHECKSUM('A') AS [Checksum value for 'A'],
BINARY_CHECKSUM('AAAAAAAAAAAAAAAAA') AS [Checksum value for 'AAAAAAAAAAAAAAAAA']
SELECT CHECKSUM('AB') AS [Checksum value for 'A'],
CHECKSUM('ABABABABABABABABABABABABABABABABAB') AS [Checksum value for 'ABABABABABABABABABABABABABABABABAB']
It seems that if put 17 times first expression as second expression result will be same.Do I misunderstand those functions or this is a BUG?
 
I don't know about the chechsum issue.

When I need to do case sensitive comparisons, I use collate. Like this...

Code:
Declare @Test Table(Col1 VarChar(20), Col2 VarChar(20))

Insert into @Test Values('Apple','APPLE')
Insert into @Test Values('Apple','apple')
Insert into @Test Values('Apple','Apple')

Select * From @Test Where col1=col2

Select * 
From   @Test 
Where  col1 collate Latin1_General_CS_AS = col2 collate Latin1_General_CS_AS

The first query uses the default collation for the server and the second query uses a case sensitive collation.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I solved case sensitive comparison just the way you did but I do not understand chechsum.
Thanx anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top