Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2004
    Posts
    10

    Unanswered: CHECKSUM() of binary data

    Hello,

    I need to generate HASH of text values for my app. I can generate hash values for normal fields using CHEKCSUM and BINARY_CHECKSUM function but it does not support checksum of text, ntext, image, and cursor, as well as sql_variant.

    How can I generate checksums of such datatype.

    Karam

  2. #2
    Join Date
    Mar 2004
    Posts
    10
    Can anybody help me?

  3. #3
    Join Date
    Mar 2004
    Posts
    80

    Re: CHECKSUM() of binary data

    CHECKSUM() by parts.
    split ntext to blocks of nvarchar(4000) and use check sum.
    Originally posted by karam_chand03
    Hello,

    I need to generate HASH of text values for my app. I can generate hash values for normal fields using CHEKCSUM and BINARY_CHECKSUM function but it does not support checksum of text, ntext, image, and cursor, as well as sql_variant.

    How can I generate checksums of such datatype.

    Karam

  4. #4
    Join Date
    Mar 2004
    Posts
    10
    Thanks for the answer.

    Can I use it for datatypes like image, sql_variant?

    A simple code on how to break it up and get a hash value will be helpful.

  5. #5
    Join Date
    Mar 2004
    Posts
    10
    Hello,

    I am still unable to figure out but how can I generate checksum of the whole column in one SQL query? Is it possible?

    Karam

  6. #6
    Join Date
    Mar 2004
    Posts
    80
    you can generate checksum() to whole column
    like
    select checksum(*) from tablename
    provided none of the columns are of text ntext image data types
    Originally posted by karam_chand03
    Hello,

    I am still unable to figure out but how can I generate checksum of the whole column in one SQL query? Is it possible?

    Karam

  7. #7
    Join Date
    Mar 2004
    Posts
    10
    Hello,

    Thats the problem. I do have those unsupported columns and I need to generate hash value from it. In MySQL (where I come from) has a md5() function to generate hash value dfor every type of data it supports.

    What I can think of is that I can convert every such data to varbinary and then employ checksum on it. But that is failing as if I convert some char values to varbinary and then running checksum on it, it is returning the same data.

    Is it feasible?

    Karam

  8. #8
    Join Date
    Mar 2004
    Posts
    80
    I don't think so.
    convert text to varchar and ntext to nvarchar.....
    and check.
    Originally posted by karam_chand03
    What I can think of is that I can convert every such data to varbinary and then employ checksum on it. But that is failing as if I convert some char values to varbinary and then running checksum on it, it is returning the same data.

    Is it feasible?

    Karam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •