March 13, 2009 at 12:16 am
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
August 24, 2010 at 12:36 pm
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
August 24, 2010 at 1:07 pm
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
August 24, 2010 at 1:22 pm
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.
August 25, 2010 at 5:00 am
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".
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply