Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing Image Data Types In SQL

How to Compare Image data types?

I need compare a file stored in DB with an uploaded file But it says that comparing Image data type is not possible I even tried to convert to nchar

(CONVERT(char(1000), FileData) 

Can anyone help me?

like image 485
Sachin Avatar asked Oct 29 '12 10:10

Sachin


People also ask

What is the data type for image in SQL?

The IMAGE data type in SQL Server has been used to store the image files. Recently, Microsoft began suggesting using VARBINARY(MAX) instead of IMAGE for storing a large amount of data in a single column since IMAGE will be retired in a future version of MS SQL Server.

How do I view images in SQL database?

How to view images stored in your database Start SQL Image Viewer and connect to your database. For SQL Server databases, tables containing blob columns will be highlighted in green in the list of database objects. Write the query to retrieve your images, and execute the query.

Can we store images in SQL database?

SQL Server allows storing files. In this article, we learned how to insert a single image file into a SQL Server table using T-SQL.


1 Answers

Don't use the image datatype it is deprecated.

Instead use the replacement datatype varbinary(max) which does not have all the limitations of image

In the meantime you can cast(FileData as varbinary(max)) to allow comparisons.

like image 72
Martin Smith Avatar answered Sep 28 '22 17:09

Martin Smith