You haven't specified a length in your
CONVERT
call. According to
the documentation[
^], the data will be truncated to the first 30 bytes.
Specify
max
as the length, and the comparison should work:
SELECT *
FROM foo As a INNER JOIN foo As b
ON CONVERT(varbinary(max), a.img) = CONVERT(varbinary(max), b.img);
If it doesn't, then you'll need to explain what the problem is.
NB: The records will only match if the bytes are exactly the same. If a single byte is different, the images are considered different, even if they look the same.