Convert VarBinary RTF blob to text in MS SQL

岁酱吖の 提交于 2019-12-11 01:27:35

问题


I am using SQL server - 2008.

Column Datatype - VarBinary

RTF File is compressed and saved to this varbinary column.

Now how to access and view data in RTF file using SQL ?

it's returns this: 㠰た㠴弰巎楛㵤㠵㜸ㄲ㠴. etc.

Sample Tried Code here:

http://rextester.com/YOFHK34016

any solution to this. in 2008 Decompress and compress function not work. how i can get RTF file as it is to text.


回答1:


That's works for me:

select convert(varchar(max),convert(varbinary(max),bv.value)) from blobValue bv

Instead using nvarchar try to use varchar. But I shuld say that this will return rtf formated text, something like:

"{\rtf1\ansi\ansicpg1251\deff0\deflang1049{\fonttbl{\f0\fnil MS Sans Serif;}{\f1\fswiss\fcharset0 Arial;}"

To get actual text from it you can use .Net dll to convert it. You can add .net dll to your database and than call it's functions from Sql script. More detailed about it: Call dll function from sql stored procedure using the current connection




回答2:


It worked for me, thanks a bunch. I used:

SELECT convert(nvarchar(max),convert(varbinary(max),[FORMULATEXT]))


来源:https://stackoverflow.com/questions/45567600/convert-varbinary-rtf-blob-to-text-in-ms-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!