2

As it is known there is a probable chance of checksum generating duplicate values, and I am supposed to find an approach which prevents checksum from generating duplicate Values... Please help

Thanks n Regards

1
  • You can't and you shouldn't need to. If you want a unique identification, a finite-size value (a checksum) isn't the way to go. Commented Jul 28, 2011 at 9:17

2 Answers 2

2

You can't. CHECKSUM can never be guaranteed unique.

MSDN for CHECKSUM says to use HASHBYTES instead which has far less chance of duplications.

However, any hashing function can not guarantee 100% that you will have no duplicates. if you want "no duplicates" then you shouldn't hash...

Sign up to request clarification or add additional context in comments.

Comments

1

Consider using HashBytes

From MSDN:

When an MD5 hash algorithm is specified, the probability of HashBytes returning the same result for two different inputs is much lower than that of CHECKSUM.

Example:

DECLARE @HashThis nvarchar(4000);
SELECT @HashThis = CONVERT(nvarchar(4000),'dslfdkjLK85kldhnv$n000#knf');
SELECT HashBytes('SHA1', @HashThis);
GO

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.