Comparing Images

  • I have inherited a 721071 row table, each with 2 stored images as image data type.

    I want to normalize this table and need to identify unique images before I can do so. Ongoing, I will need to compare new images to those in my new image table.

    Any suggestions on identifying distinct images and comparing images would be greatly appreciated.

  • I hope you are storing it in text/ntext datatype fields. In that case you can try using substring to compare as chuncks of 8000 charaters.

    use northwind

    SELECT E1.EmployeeID ,E2.EmployeeID

    FROM Employees E1 INNER JOIN Employees E2 ON

    substring(E1.photo, 1, 8000) = substring(E2.photo, 1, 8000)

    You can find the length of the photo like

    SELECT max(datalength(photo)) FROM Employees

    If the datalength is more that 8000 bytes then use multiple substrings as

    SELECT

    E1.EmployeeID

    ,E2.EmployeeID

    FROM

    Employees E1 INNER JOIN Employees E2 ON

    substring(E1.photo, 1, 8000) = substring(E2.photo, 1, 8000)

    AND substring(E1.photo, 8001, 8000) = substring(E2.photo, 8001, 8000)

    AND substring(E1.photo, 16001, 8000) = substring(E2.photo, 16001, 8000)

    But this would be very very slow process of comparision ...

    HTH,

    Vinod Kumar


    Vinod Kumar

  • These are datatype image. As I said I inherited this mess and never would have taken this approach, but now I need to remedy the situation.

  • You cannot do for Image datatypes the solution I had given earlier ...

    Such comparision is not possible in SQL Server. You would like to look into some other tool to do this activity for you.

    HTH,

    Vinod Kumar

    Vinod Kumar


    Vinod Kumar

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

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