• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 572
  • Last Modified:

How to read metadata of JPEG using T-SQL?

I've uploaded some JPEG images to a filestream column in SQL Server 2008. I want to extract the metadata from these into another table containing columns that represent each item of metadata. I'm not sure about the structure of metadata though. When I place my cursor over a photo icon in Explorer a caption appears containing five items (date taken, dimensions etc). Is this all there is, or are there more items of metadata embedded in the file?

Secondly, how can I read this data using T-SQL?
1 Solution
Here's a link for metadata: http://www.exiv2.org/tags.html

Attached is some code I use to get some of that info.
Surendra NathTechnology LeadCommented:
it may be a little difficult to do it in database itself...
but it will be easy to do it as a .NET library using the below approach


So, what I suggest is to create a library to get the metadata using .NET using the above approach and use SQLCLR to add this library and act on the input JPEG and populate your tables.

that should be an easy one rather finding the whole stuff in TSQL.
TimHudspithAuthor Commented:
ktaczala - I want to use your code inside a loop that iterates the rows of my SQL Server table containing the photos. The problem is that I can't set the SqlFileStream object. I've set this up as a separate question:

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now