Is it possible to find out what file is stored in SQL Server? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Is it possible to find out what file is stored in SQL Server?

I have an SQL Server Database shared with me. I can see all the other data very clearly i.e text, numbers, boolean, dates BUT It has a table called "Keywords" where we have 2 columns - - Id (int) - Doc (FileData) Although I can read this binary data in Doc column through C# code but I am not able to make it out what type of file is stored in it? It seems every row in Keywords table represent a file which is stored under Doc column using varbinary type ( variable size binary data, blob). Is there a way I can find out which file is it? I have tried to save the file as Pdf, png, jpg in my file system from database but no luck. There is also no C# code related to Keywords table in the solution. Any help would be highly appreciated, this table belongs to my friend's client who wants to migrate existing DB to MongoDB and this is the final pending task.

5th Feb 2022, 10:00 AM
Morpheus
Morpheus - avatar
4 ответов
+ 3
I'm far from being an expert on this. But without further information my guess would be that they are BLOBs. https://www.educba.com/sql-blob/ Does the database come without any documentation?
5th Feb 2022, 10:38 AM
Simon Sauter
Simon Sauter - avatar
+ 3
Simon Sauter Yes it's a binary data BLOB. It's "varbinary" type to be exact in T-SQL in SQL Server. Also there's no documentation either in DB or in code. sadly I cannot even find the model class for that Keyword table or any file ingestion code.
5th Feb 2022, 10:59 AM
Morpheus
Morpheus - avatar
+ 2
As a more serious answer, maybe this helps? https://andyspecht.github.io/2017-06-23-extracting-images/
5th Feb 2022, 12:11 PM
Simon Sauter
Simon Sauter - avatar
+ 1
I guess the pragmatic (aka lazy) approach would be to just say "if no-one knows what it is then obviously no-one needs it." Of course this comes with the risk that the client might also take the pragmatic approach and say "if you can't figure it out then we obviously don't need *you*."
5th Feb 2022, 12:06 PM
Simon Sauter
Simon Sauter - avatar