• Comments posted to this topic are about the item BINARY CHECKSUM


  • Anyone who still uses text variables should be shot, especially because it makes me read the question wrong.

    Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: for significant large values of 2

  • Hey Ronald - do you have a statistics background? I just noticed your sig line and it reminded me of an old statistician joke... 🙂

  • Like Ronald, I doubt I'll have much use for a "text" datatype, but we do have XML in our databases so this QOD was valuable to me in pointing out that non-comparable datatypes are ignored. This script is modified from the original QOD to show the danger of depending on checksum or binary_checksum to flag certain changes.

    Declare @FirstCksum int

    CREATE TABLE #myTable (column1 xml,column2 int);

    INSERT INTO #myTable VALUES ('',109);

    select * from #mytable

    SELECT @FirstCksum = BINARY_CHECKSUM(*) from #myTable;

    update #myTable set column1='values' where column2 = 109

    select * from #mytable

    SELECT Case when BINARY_CHECKSUM(*) = @FirstCksum

    then 'No Change'

    else 'Table Modified'

    end as TableChanged

    from #myTable;

    DROP TABLE #myTableYes, it returns "No Change" because only the int column is considered by the function.

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

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