How to encode language specific chars while converting varbinary() to varchar(max) in SQL Server 2012?

前端 未结 2 1475
忘了有多久
忘了有多久 2020-12-10 21:58

I am trying to convert a database column DATA from varbinary() to varchar(max) in SQL Server 2012.

I am using this code to han

2条回答
  •  -上瘾入骨i
    2020-12-10 22:32

    try NVARCHAR

    Select convert (NVARCHAR(max),DATA) FROM  [dbo].[TABLE_NAME]
    

    EDIT:

    SQL Server does not support handling of UTF8. To convert your binary value you have to write you own function. The easiest way to do that is to use CLR.

    You can use this as a model: How to return an nvarchar(max) in a CLR UDF?

    Just replace the regex code with the Encoding.UTF8.GetString

提交回复
热议问题