Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get Hex from varchar?

1,424 views
Skip to first unread message

yanivc.

unread,
Dec 20, 2007, 2:51:42 AM12/20/07
to
Hi.
I have a table with nvarchar column.
I need to get from a single record from this column the
Hexdecimal value for each "Letter".
How can I do it?
I could not find the right function to do so.
The string not necesarilly in ASCII and can contain some
"special" characters and letters from different languages.
The Data Server is ASE 12.5.3 and the character set is UTF
8.
Thanks,
Yaniv

Bret Halford

unread,
Dec 20, 2007, 11:53:28 AM12/20/07
to
depends a little on what datatype you want for the output.

select convert(binary(n), column)

will get you a binary value (which ISQL displays as a string).

If you want that value to actually be in a string in ASE, you need to
go one step further

select bintostr(convert(binary(n),column))


1>
2>
3> create table z (a varchar(20))
4> go
1> insert z values ("abcxyz")
2> go
(1 row affected)
1> select convert(binary(20), a) from z
2> go

------------------------------------------
0x61626378797a0000000000000000000000000000

(1 row affected)
1> select bintostr(convert(binary(20), a)) from z
2> go

----------------------------------------
61626378797a0000000000000000000000000000

(1 row affected)

0 new messages