Convert RTF to varchar in SQL Server

别说谁变了你拦得住时间么 提交于 2020-06-17 03:21:07

问题


I am trying to convert a varbinary to varchar but it is causing some unwanted characters to show up, as shown below. Could someone please let me know if there is any best way to do it.

I'm trying the following query

SELECT
    BLOB_CONTENTS, 
    CONVERT(VARCHAR(MAX), [BLOB_CONTENTS]), 
    CONVERT(NVARCHAR(MAX), [BLOB_CONTENTS]) 
FROM 
    [hie_temp].[V500].[CE_BLOB] 
WHERE
    EVENT_ID = '760365' 

varbinary code like this :

0x05028A64F2A9488645100E84053281148A4324080A0412A1209E4C2791CB2208EC7A3F2090C7

I am getting something like this

Šdò©H†E„2ŠC$ ¡ žL'‘Ë"ìz? Ç…ˆÔl8Œ£hÐr-ŒDBy¨O)B„IÑH\CdòA"¤Ò£Ä²)L‚V “…‚‘<¦H©@‰$â!$‡$“é¸ù°A&ˆ Ö˜M–”DŠ‘EåBI6Ý á2ˆœ (•H¥(á„Nœ“H$ÂIR9")•ñ‘’¸€„A)J¶«|xb1ÊÅã‘Ä€ŒLéE£ XÄr 

回答1:


RTF is not plain text, you need to write a procedure/function to convert RTF to text, see here.

Alternatively you can do it in your programming language, see this post for an example in C#.



来源:https://stackoverflow.com/questions/51201069/convert-rtf-to-varchar-in-sql-server

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