I have a back-end java app in which I would like to have the app automatically extract VARBINARY data from the database, and then use this data to download files to the user’s hard drive.
I can use bulk copy program to extract the VARBINARY contents from the table like so:
bcp "select CONTENTS from DOCUMENT_TABLE where DOC_ID = 123" queryout "C:usersfredDesktopBCP_results.pdf" -c -d MyDatabase -S MyDatabaseServer
Where CONTENTS is a VARBINARY column in DOCUMENT_TABLE that in this case contains the data for a pdf file.
Although the resulting file BCP_results.pdf is created and contains the data, it’s definitely not in the form of a readable pdf file.
Can anyone tell me if there is a way to use BCP or anything else to programmatically extract VARBINARY data and download it to a readable file such as a pdf file?
If possible, I would also like to be able to do this for xlsx files, .tif files, etc.
Thanks much
2