Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Checksum givingtwo different values while Comparing VarBinay(MAX) Expand / Collapse
Author
Message
Posted Friday, March 13, 2009 12:16 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, November 22, 2010 3:02 AM
Points: 31, Visits: 116
Hi All,

I'm facing a strange issue in my project.We are developing an windows application in which store the contents of (Word,Excel) in varbinary format in database(SqlServer2005).Our requirement is that we need to compare the current content of the word or excel with that of the content which is already saved in the database.If there is any change in the content then only i need to update the database,for this comparison we are using checksum.But the issue we are facing is that eventhough i havn't made any changes to the word document, on saving when i try to compare the previous value and current value using checksum in the database , it gives out two different values.Can anyone please help on this.

Thanks in advance,

Regards,

Vibindas
Post #674944
Posted Tuesday, August 24, 2010 12:36 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 4, 2013 6:07 PM
Points: 3, Visits: 27
You can find a number of posts on this subject by doing a web search on "SQL Server Checksum false positives". Something related but not discussed as much are the rows that are different yet generate the same checksum value. SQL Server 2005 can generated checksums that are exactly the same in spite of the fact that the data is different. To try it for yourself:

CREATE TABLE DupeTest
(FieldA INT,
FieldB INT,
RowChecksum AS CHECKSUM(FieldA, FieldB))

INSERT DupeTest (FieldA, FieldB)
VALUES (384, 170005);
INSERT DupeTest (FieldA, FieldB)
VALUES (387, 170021);

SELECT * FROM dupetest

DROP TABLE DupeTest
Post #974357
Posted Tuesday, August 24, 2010 1:07 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 3:42 AM
Points: 1,943, Visits: 20,180
deleted: didnt read the OP question thoroughly !!

______________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Post #974390
Posted Tuesday, August 24, 2010 1:22 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, October 4, 2013 6:07 PM
Points: 3, Visits: 27
An interesting solution but adding another column, though guaranteed to be unique, cannot guarantee checksums that will always differ. As a matter of fact, given the original issue, it may even cause rows that differ and have different checksums to now have duplicate checksums.
Post #974402
Posted Wednesday, August 25, 2010 5:00 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, September 11, 2014 12:06 PM
Points: 290, Visits: 199
If I understand your question:

You are saving a copy of an Excel spreadsheet (or Word document) to the database.
You then open that Excel spreadsheet, make no changes to it, and Save it.
You are now surprised that the checksum of the file is different than it used to be.

That's most likely because the files are different.

Just now I made a copy of an Excel file. (Just a plain file copy, nothing to do with SQL Server).
I opened that file in Excel.
I did absolutely nothing other then press Save, and then Exit.
I compare the file against the copy I just made, and I see that the file has changed.
It's not surprising that the checksums on the two files would be different, since the files are different, even though the two files hold the same "content".







Of course I've got free will. What other choice do I have?
Post #974737
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse