I inherited a database with a table (300 gigabytes) full of SQL Image data type. I understand that this type of data is depreciating.
As a regular cleanup, I want to remove all duplicate Image from the table where certain conditions are met.
How to efficiently compare binary data using SQL? Is the equality operator = sufficient
Here is the scenario:
Table 'Paperwork' int ID int EmployeeID int AnotherID int AnotherFKID image Attachment
I want to find all rows where the values โโof Attachment , EmployeeID , AnotherID and AnotherFKID match. This must be done with minimal impact on the database, as there are more than 1,116,313 rows.
Edit
The SQL Server Image data type does not support LIKE or the usual comparison operators.
Edit
Thanks to @Martin who suggested that Image be added to varbinary. I added to this to get the MD5 checksum using Hashbytes
HASHBYTES('MD5',CAST(cast([Attachment] as varbinary(max))as varbinary)) AS AttachmentMD5
source share