Compare two IMAGE fields

  • Hi,

    how to Compare two IMAGE fields, i try the following:-

    SELECT itemphoto.item_no, itemphoto.photo

    FROM [2560].[2560].itemphoto itemphoto ,[erpinv41].[ims].itemphoto MAINPHOTO

    where itemphoto.photo <> MAINPHOTO.photo

    but i get the follwoing error:-

    Msg 402, Level 16, State 1, Line 1

    The data types image and image are incompatible in the not equal to operator.

    best regards

  • Convert the image field to varbinary to do your comparison.

    create table foo

    (

    img image

    )

    go

    select *

    from foo a, foo b

    WHERE convert(varbinary,a.img) = convert(varbinary,b.img)

    Gary Johnson
    Sr Database Engineer

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

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