Friday, January 2, 2009

SERVERPROPERTY('EditionID') BOL Value Wrong

I'm trying to write a UDF that returns version information, and to make a long story short, I was executing:

SELECT SERVERPROPERTY('EditionID')

...and getting back a value of -133711905. In BOL (http://msdn.microsoft.com/en-us/library/ms174396.aspx ), the table for 'EditionID' is:

-1253826760 = Desktop 
-1592396055 = Express 
-1534726760 = Standard 
 1333529388 = Workgroup 
 1804890536 = Enterprise 
 -323382091 = Personal 
-2117995310 = Developer 
  610778273 = Enterprise Evaluation 
 1044790755 = Windows Embedded SQL
 4161255391 = Express with Advanced Services

Base data type: int

Hmmm... my value doesn't appear? After an embarressing amount of bit twiddling, I finally noticed that the last value in the table, 4161255391, and the value I was getting, -133711905, were actually the same: 0xF807B7DF. Okay, I mused, it's a signed/unsigned issue - but SQL Server doesn't have any unsigned 32-bit integers. That's when I noticed that 4161255391 was an awful big number to be a 32-bit signed integer (a.k.a., INT). So, this is a "documentation bug": the table should use the signed -133711905 value, not the unsigned 4161255391. Maybe this will help someone else.

0 comments:

Post a Comment