Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4055040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:39:04+00:00 2026-05-20T14:39:04+00:00

I am trying to get RTF data out of a image date field in

  • 0

I am trying to get RTF data out of a image date field in MS SQL. Not so easy.

The issue is that when I do a straight binary dump of the data field it is not in RTF format.
Let me explain what is going on. When I create a RTF file with Wordpad, and write that data to a varbinary(max), and reconvert it, the result is jiberish.

Code to put RTF data into MS SQL:

exec master..sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
exec master..sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
DECLARE @objStream INT
DECLARE @imageBinary VARBINARY(MAX)
DECLARE @filePath VARCHAR(8000)

select @imageBinary=Report from Mytable WHERE EncounterID=7
select @filePath='c:\temp\report.rtf'
EXEC sp_OACreate 'ADODB.Stream', @objStream OUTPUT
EXEC sp_OASetProperty @objStream, 'Type', 1
EXEC sp_OAMethod @objStream, 'Open'
EXEC sp_OAMethod @objStream, 'Write', NULL, @imageBinary
EXEC sp_OAMethod @objStream, 'SaveToFile', NULL,@filePath, 2
EXEC sp_OAMethod @objStream, 'Close'
EXEC sp_OADestroy @objStream

In binary, the first part of this file goes like this
0x7B 5C 72 74 66 31 5C 61 6E 73 69 5C 61 6E 73 69)
(ascii {\rtf1\ansi\ansi )
However, the varbinary field looks like this:
0xB0 04 01 00 0E 00 00 00 00 00 00 00 00 00 09 00

And when i take that data out of the database (by using the reverse of the procedure above), it is not a recognizable RTF file. So, somehow MS is converting it in a way i can’t recognize. If I can figure out how to convert it back to ascii text then I can continue with my application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:39:05+00:00Added an answer on May 20, 2026 at 2:39 pm

    The following works for me. I suspect the issue must be how you are saving the file to the database.

    CREATE TABLE #BlobTest
    (
    blob varbinary(max) 
    )
    
    INSERT INTO
        #BlobTest (blob)
    SELECT  BulkColumn FROM Openrowset( 
          Bulk 'C:\testing.rtf', 
          SINGLE_BLOB) AS blob
    
    GO
    
    exec master..sp_configure 'show advanced options', 1;
    GO
    RECONFIGURE;
    GO
    exec master..sp_configure 'Ole Automation Procedures', 1;
    GO
    RECONFIGURE;
    GO
    DECLARE @objStream INT
    DECLARE @imageBinary VARBINARY(MAX)
    DECLARE @filePath VARCHAR(8000)
    
    select @imageBinary=blob from #BlobTest
    select @filePath='c:\report.rtf'
    EXEC sp_OACreate 'ADODB.Stream', @objStream OUTPUT
    EXEC sp_OASetProperty @objStream, 'Type', 1
    EXEC sp_OAMethod @objStream, 'Open'
    EXEC sp_OAMethod @objStream, 'Write', NULL, @imageBinary
    EXEC sp_OAMethod @objStream, 'SaveToFile', NULL,@filePath, 2
    EXEC sp_OAMethod @objStream, 'Close'
    EXEC sp_OADestroy @objStream
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get a random string out of ListArray on the button pressed. Always
Trying to get my arrow image to stick to the right of the anchor
I am trying get content from the link https://....com:8455 where Server's certificate is not
When trying get in memcache client, getting the below excepton. Caused by: java.io.IOException: com.fet.myclass.webservice.data.DataList
Trying to get a value from a object isn't working out. class Asset <
after pulling my hair out for two days trying to figure this issue out
How do I get the text in RTF of a RichTextBox ? I'm trying
I am trying to add a image to a RTF document which I am
So i am trying get 2 div-containers which both should contain centered text (Both
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.