need help on checksum

  • hi all ,
    i tried to read the checksum part in  MSDN , checksum checksum
    any help exactly how this processing internally .It is creating hash index , on the column values based on the arguments. but here in the below one can you help me understanding how %26 and 97 is calculated
     I may be asking very basic question ,but want to understand this part .

    randome value generation :

    CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) AS Lastname
    (ABS(CHECKSUM(NEWID())) % 9999999) + 1,7) AS Phone, --Phone numvbers 0000001 to 9999999,
    (ABS(CHECKSUM(NEWID())) % 120000) + 5000 AS Salary

  • The CHECKSUM of the value returned by NEWID is a signed integer (maybe a big integer, don't recall), so the ABS insures that the number is positive.  Then the MODULO of this value is taken, in this case using 26 which will return a value between 0 and 25 (inclusive).  This value is then added to 97 which results in a value between 97 and 122.  This value is then used to return the ASCII character related to that number which results a letter between 'a' and 'z' (always a lower case value).

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply