Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table with varbinary datatype (file stream enabled) column which store pdf files as binary , form that i can get result as which of file have 'invoice' word using following query.

SELECT * FROM FileStore WHERE CONTAINS(Document,'invoice')

Here "Document" is varbinary column which store pdf and word files as binary.

From this i want to get words which appear how many times, i mean number of occurrences.

E.G: In one of the pdf got 'invoice' word 5 times , so want to count how many time word appear in that table using query,

Note: i am asking in varbinay datatype, not for nvarchar datatype.

What I have tried:

I tried with string can, but from binary cant found solution.
Any solution much appreciated.

Thanks and Regards

Updated 8-Aug-22 19:32pm

1 solution

That's not easy - there are ways which work to find if a string exists in a VARBINARY field:[^] but they are subject to problems like wildcard expansion as mentioned there.
And they aren't going to help you count occurances i=within a single PDF file.

To be honest, you would be much better off doing the bulk of this in your presentation language - it will have much better string / binary data handling than SQL does.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900