Does SQL Server 2012 have a function or other way to convert a varchar column that contains ASCII to plain text? -


i've inherited database table has nvarchar(max) column containing ascii numbers. need convert , replace them plain text. possible using sql function?

from:

034 067 111 110 118 101 114 116 032 077 101 044 032 068 097 114 110 032 105 116 033 033 034

to:

"convert me, darn it!!"

thanks all

test data

declare @table table (ascii_col varchar(1000)) insert @table values  ('034 067 111 110 118 101 114 116 032 077 101 044 032 068 097 114 110 032 105 116 033 033 034') 

query

;with cte as( select char(split.a.value('.', 'varchar(100)')) char_vals   (select                cast ('<m>' + replace(ascii_col, ' ', '</m><m>') + '</m>' xml) data           @table)        cross apply data.nodes ('/m') split(a)     ) select (select  '' + char_vals          cte          xml path(''),type).value('.','nvarchar(max)') 

result

"convert me, darn it!!" 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -