How Can I Use HASHBYTES Function on Image or Text Columns? RRS feed

  • 问题

  • I have a table with image-type column and text-type column, such as TestTable(intColumn int, imageColumn image, textColumn text). I want to use HASHBYTES function to detect data change, and then call these sql in my C# code.

    But HASHBYTES could only deal with data type of "varchar", "nvarchar", "varbinary", so my old code is:

    select *,

    Binary_CheckSum(HASHBYTES('MD5', CONVERT(nvarchar(max), intColumn)), HASHBYTES('MD5', CONVERT(nvarchar(max), imageColumn))

    , HASHBYTES('MD5', CONVERT(binary(max), textColumn)))

    from dbo.Test

    In this way, image or text will be truncated to 8000 bytes if their length is over 8000 bytes.

    How can I use HASHBYTES function on image, text or ntext columns?



    Thanks for your patience,


    • 已移动 doukooo 2011年3月3日 4:16 C#问题 (发件人:微软学生讨论专区)
    • 已移动 feiyun0112 2011年3月4日 1:39 (发件人:Visual C#)
    2011年2月24日 3:30