Feed Icon  


  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics


Open Source Projects



Checking Checksum

Posted in Sql and Xml at Tuesday, December 7, 2004 2:18 AM Pacific Standard Time

I use checksum in SQL Server to distinguish between records that are different instead of comparing the character strings in them. My application was working fine until I added a lot of records and suddenly things started getting messy. After taking a look at it I determined the issue was that the checksums were being computed as being equal even though the columns had different values. Here is one example:

select checksum('where myval in (7004054,7004055)') a, checksum('where myval in (7003888,7003889)') b

  a b
1 1796206651 1796206651


Notice that the two values are the same even though the where clause is very different. There was an easy fix in my case though:

select checksum(N'where myval in (7004054,7004055)') a, checksum(N'where myval in (7003888,7003889)') b

  a b
1 1992021988 -375513627

So in this case I only had to change the variables I used to calculate the checksums from varchar to nvarchar and everything started working. This is going to force me to take a much closer look at my process though.

Comments are closed.