SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 NTEXT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

osirisa
Constraint Violating Yak Guru

USA
288 Posts

Posted - 03/20/2013 :  16:04:30  Show Profile  Click to see osirisa's MSN Messenger address  Reply with Quote
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

USA
15654 Posts

Posted - 03/20/2013 :  16:43:29  Show Profile  Visit robvolk's Homepage  Reply with Quote
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

USA
288 Posts

Posted - 03/20/2013 :  21:55:54  Show Profile  Click to see osirisa's MSN Messenger address  Reply with Quote
Robvolk Thank You so very much.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000