Converting text into rtf format in mssql

tobz 161 Reputation points
2020-12-22T18:29:07.773+00:00

Hi everyone,

I have data that is in word document that I want to insert into the database, this data is formatted and I will like to save the formats in the database as well using the rtf format.

Can someone help me on how I can generate the rtf format for the data in the word document so that I can store the rtf instead of the plain text in the database.

Thanks

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,666 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 113.7K Reputation points MVP
    2020-12-22T22:24:38.743+00:00

    SQL Server does not really care about the format. If it is text data you can save the document in an nvarchar(MAX) or varchar(MAX) column. If the data is binary, such as an .docx file, you need to use varbinary(MAX). I believe RTF is a text format, but I am not sure. varbinary(MAX) will always work any way.

    If you want to transform the document, you need to do this outside SQL Server, and for how to do it - this is the completely wrong place to ask.

    SQL Server receives the generated bytes and that is what it returns. SQL Server never interpretes the bytes on its own account - with one exception: if you add a full-text index on a database, it is able to read PDFs, Word documents etc, provided that you somewhere store information about the format.

    0 comments No comments

  2. EchoLiu-MSFT 14,591 Reputation points
    2020-12-23T06:40:26.753+00:00

    Hi @tobz ,

    Please refer to the following steps to set:

    Step1-Open your word file,find the'File' in the upper left corner, as shown in the figure

    50702-image.png

    Step2-Then click "File" in the upper left corner, and find "Save As" in the submenu, as shown in the figure

    50586-image.png

    Step3-In the pop-up "Save As" window, select the location to save the file, modify the file type to "RTF" format, and click Save. As shown

    50741-image.png

    If you have any question, please feel free to let me know.
    If the response is helpful, please click "Accept Answer" and upvote it.

    Regards
    Echo


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Hot issues November--What can I do if my transaction log is full?
    Hot issues November--How to convert Profiler trace into a SQL Server table

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.