Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert rtf blob to text in MS Sql

I working with database. In this database I have a table with blob field. This field contains rtf text. If I'am doing like this:

select convert(nvarchar(max),convert(varbinary(max),blob_column)) from table_with_blob

it's returns this: せ〰〰〴ㄷⴶ㠰た㠴弰巎楛㵤㠵㜸㔰⁝ﳲ茶¢∠ⰳㄲ㠴.

So my question is how to convert this rtf blob to text using MS Sql 2008?

like image 581
Gleb Avatar asked Feb 05 '26 00:02

Gleb


1 Answers

try with this, it should work

select convert(varchar(max),convert(varbinary(max),blob_column)) from table_with_blob

take the reference from below script -

DECLARE @blob VarBinary(MAX) = CONVERT(VarBinary(MAX), 'test');
-- show the binary representation
SELECT @blob;
-- this doesn't work
SELECT CONVERT(NVarChar(100), @blob);
-- but this does
SELECT CONVERT(VarChar(100), @blob);
like image 170
Naveen Kumar Avatar answered Feb 06 '26 12:02

Naveen Kumar