April 9, 2008 at 6:24 am
If I use checksum() in SQL2000 will I get the same results in 2005 and later versions.
EX:
select checksum('abcdefg') -- yields -2039903324
Thanks
ST
April 9, 2008 at 6:33 am
Heh... I don't think anything is guaranteed across versions, ST... but the same number is returned in both SQL Server 2000 and 2005 when I run your sample code of...
select checksum('abcdefg') -- yields -2039903324
--Jeff Moden
Change is inevitable... Change for the better is not.
April 9, 2008 at 6:37 am
souLTower (4/9/2008)
If I use checksum() in SQL2000 will I get the same results in 2005 and later versions.EX:
select checksum('abcdefg') -- yields -2039903324
Thanks
ST
No, you will not.
the above statement is wrong See my post later in the thread.
Regards,
Andras
April 9, 2008 at 6:42 am
Andras Belokosztolszki (4/9/2008)
souLTower (4/9/2008)
If I use checksum() in SQL2000 will I get the same results in 2005 and later versions.EX:
select checksum('abcdefg') -- yields -2039903324
Thanks
ST
No, you will not.
Regards,
Andras
Just as an example, I ran:
drop table foo
create table foo
(
a int primary key
identity(1, 10),
c varchar(10) default 'aaaa' COLLATE French_CI_AS,
b as checksum(a, c))
go
insert into foo
default values
go 10
select *
from foo
on 2000, 2005 and 2008, the checksum was returning different values on 2000, 2005 and 2008.
And this is wrong, see my post later
It may be that the difference is because there are multiple columns, but as Jeff mentioned, you should not assume that you will get the same number on the various server versions. You could use HashBytes, which should behave consistently.
Regards,
Andras
April 9, 2008 at 7:25 am
Andras Belokosztolszki (4/9/2008)
souLTower (4/9/2008)
If I use checksum() in SQL2000 will I get the same results in 2005 and later versions.EX:
select checksum('abcdefg') -- yields -2039903324
Thanks
ST
No, you will not.
Regards,
Andras
How can you say that? I just ran ST's code in 2k and 2k5 and, all other things being equal, they both come up with the exact same answer.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 9, 2008 at 8:24 am
Jeff Moden (4/9/2008)
How can you say that? I just ran ST's code in 2k and 2k5 and, all other things being equal, they both come up with the exact same answer.
Hmmm, you are right. I made a mistake.
In my example I should have used
b as checksum(a, c COLLATE French_CI_AS)
(my dbs had different collations, these affected the computed column collation, the collation affected the checksum).
My bad, apologies.
Regards,
Andras
April 9, 2008 at 8:26 am
Absolutely not a problem, Andras... thanks for double checking.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 9, 2008 at 8:31 am
Here is how CHECKSUM is calculated and how you break it.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=70832
N 56°04'39.16"
E 12°55'05.25"
April 9, 2008 at 8:34 am
Nicely done, Peter!
--Jeff Moden
Change is inevitable... Change for the better is not.
April 9, 2008 at 8:42 am
Peso (4/9/2008)
Here is how CHECKSUM is calculated and how you break it.
Very Impressive!
Have you had a look at how MS handles a list of values?
CHECKSUM seems to do different things with collated strings (the same problem I got burned with)
select dbo.fnPesoTextChecksum('aaa' COLLATE French_CI_AS)
select checksum('aaa' COLLATE French_CI_AS)
seem to return different numbers.
Regards,
Andras
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply