Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 NTEXT

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2013-03-20 : 16:04:30
First, Thank You to anyone who dare to answer this question. I have a table with a column StoredDocwith data type "NTEXT". This table contains pdf files. I need to read from this SQL database and extract this pdf(s) files.
The problem is that usually to read a pdf file using VB.Net the data type needs to be varbinary(MAX).
Anyway. Does anyone know how to transform this column into varbinary(MAX).

Thank You.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2013-03-20 : 16:43:29
Create a view like the following:
CREATE VIEW myView AS 
SELECT CAST(CAST(StoredDoc AS NVARCHAR(MAX)) AS VARBINARY(MAX)) StoredDoc FROM myTable;
Then write your application to read from the view instead of the table. Add any needed columns to the view definition when you create it.

FYI it's possible that the PDF data was corrupted when converting it to NTEXT, especially if it was compressed (most PDFs are).
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2013-03-20 : 21:55:54
Robvolk Thank You so very much.
Go to Top of Page

arronlee
Starting Member

12 Posts

Posted - 2016-01-19 : 23:58:22
Hi, osirisa.
Thanks for sharing your problem. As for me, I have seldom tried to read from this SQL database and
extract this pdf files before. Have you ever worked it out? I wonder whether you have any exprience about pdf extraction process. Because there is something wrong with my pdf reader. I need convert pdf into text or other formats. Any suggestion will be appreciated. Thanks in advance.



Best regards,
Lee
Go to Top of Page
   

- Advertisement -