Your technology certification is waiting. Enroll in Cloud Class ®
CREATE FUNCTION fnCharToUCSHex(@input varchar(max))
DECLARE @position int, @asciicode int, @ResultVar varchar(max), @hex varbinary(2)
SET @ResultVar = ''
SET @position = 1
WHILE @position <= DATALENGTH(@input)
SET @asciicode = ASCII(SUBSTRING(@input, @position, 1))
SET @position = @position + 1
SET @hex = CONVERT(VARBINARY(2), @asciicode)
SET @ResultVar = @ResultVar + Right(master.dbo.fn_varbintohexstr(@hex), 4)
Open in new window
The older UCS-2 (2-byte Universal Character Set) is a similar character encoding that was superseded by UTF-16 in version 2.0 of the Unicode standard in July 1996.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.