Converts a sequence of hexadecimal digits to a string of its equivalent alphanumeric characters or varbinary data.
select bintostr(sequence of hexadecimal digits)
1> select bintostr(0x723ad82fe) 2> go
----------------------------------- 0723ad82fe
In this example, the in-memory representation of the sequence of hexadecimal digits and its equivalent alphanumeric character string are:
Hexadecimal digits (5 bytes) |
|||||||||||||||||||
0 |
7 |
2 |
3 |
a |
d |
8 |
2 |
f |
e |
||||||||||
Alphanumeric character string (9 bytes) |
|||||||||||||||||||
0 |
7 |
2 |
3 |
a |
d |
8 |
2 |
f |
e |
The function processes hexadecimal digits from right to left. In this example, the number of digits in the input is odd. For this reason, the alphanumeric character sequence has a prefix of “0” and is reflected in the output.
declare @bin_data varchar(30) select @bin_data = 0x723ad82fe select bintostr(@bin_data) go
---------- 0723ad82fe
Any invalid characters in the input results in null as the output.
The input must be valid varbinary data.
A NULL input results in NULL output.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute bintostr.