Script or utility to export/extract files from varbinary(max) column in SQL
$30-250 USD
Completed
Posted over 3 years ago
$30-250 USD
Paid on delivery
I have PDFs stored in a SQL database, some are compressed and some are not. I an export just fine but I cannot view the compressed ones. When I "check the file type" on the compressed files, I'm told it is a ZLIB file. I don't know how to uncompress these.
More info:
I can export and view all files that are not compressed just fine with this script. The ones that are compressed I can not open or extract, I've tried winzip, 7zip, gzip, 9zip, securezip, etc -- all say it's an unrecognizable format...
I don't know how the files were inserted (it was a software that I don't have access to).
Tell me what you can do for me and how much you will charge. Is there a command I can type into SQL to export the compressed files uncompressed or do I need an app to run in the command line after the export or something else?
DECLARE CURSOR_ProductIds CURSOR FOR (select top 10 [login to view URL] from ViewDocumentManagement v inner join RawAttachment c on [login to view URL] = [login to view URL] where [login to view URL] = '1' )
DECLARE @ProductId varchar(50);
OPEN CURSOR_ProductIds
FETCH NEXT FROM CURSOR_ProductIds INTO @ProductId
WHILE (@@FETCH_STATUS <> -1)
BEGIN
DECLARE @ImageData varbinary(max);
SELECT @ImageData = (SELECT convert(varbinary(max), attachmentcontent, 1) FROM [login to view URL] WHERE attachmentuid = @ProductId);
DECLARE @Path nvarchar(1024);
SELECT @Path = 'c:\temp';
DECLARE @Filename NVARCHAR(1024);
SELECT @Filename = (SELECT attachmenttype + '_' + filename FROM ViewDocumentManagement WHERE attachmentuid = @ProductId);
DECLARE @FullPathToOutputFile NVARCHAR(2048);
SELECT @FullPathToOutputFile = @Path + '\' + @Filename ;
DECLARE @ObjectToken INT
EXEC sp_OACreate '[login to view URL]', @ObjectToken OUTPUT;
EXEC sp_OASetProperty @ObjectToken, 'Type', 1;
EXEC sp_OAMethod @ObjectToken, 'Open';
EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @ImageData;
EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @FullPathToOutputFile, 2;
EXEC sp_OAMethod @ObjectToken, 'Close';
EXEC sp_OADestroy @ObjectToken;
FETCH NEXT FROM CURSOR_ProductIds INTO @ProductId
END
CLOSE CURSOR_ProductIds
DEALLOCATE CURSOR_ProductIds
I can try to help with recognizing of required data because I am Senior MS SQL Developer with 10-plus years' seniority and with extended professional development expertise.
$140 USD in 2 days
5.0 (47 reviews)
5.2
5.2
7 freelancers are bidding on average $176 USD for this job
Hello,
The zlib is standard compression on Windows based environment, so you need to decompress it using either ready-to-use application such as winzip or any other apps. Or you could write a small tools which will read your field in binary format and decompress it for getting the binary raw data then store to the PDF file as well. I could write a tools like that, but I need to know the connection string to your database and the table structure where your PDF stored. I will write the code ine ither vbs or .NET.
Let me know which one you prefer
Best Regards,
Khamid
Hi I have 15 years experience in developing software application using C# , SQL Server and python. I will be able to build a code that can export both compressed and uncompressed ZLIB based pdf files for you.
I am writing piece of Code to demonstrate the Proof of concepts Please ping me offline to discuss further.
Hello Sir,
I have vast experience of building application in MS SQL
More than 4 year experience.
More than 20 projects working.
I am ready to work for you.
Hope you look forward to work with me.
Thank You.
Hello, sir. I hope you and your family are safe from the Covide-19
Thank you for posting the job "Script or utility to export/extract files from varbinary(max) column in SQL".
I am Grisha from Armenia who has rich experience of Database
As I have read your project spec carefully, I am very confident on your project.
Please send me a message to discuss further through PM.
Best regards.
Hi
I have already developed script to automate import & export of varbinary SQL field. Please provide me an opportunity to work on this project.
Thanks,
Kiran