Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show hexadecimal dump of string

Is there any way to obtain an hexadecimal dump of a string in SQL Server? It'd be useful to troubleshoot character set and collation issues.

In MySQL you'd do SELECT HEX('€uro') and in Oracle you'd do SELECT DUMP('€uro') FROM DUAL.

like image 622
Álvaro González Avatar asked Sep 17 '10 10:09

Álvaro González


1 Answers

SELECT CAST('€uro' AS VARBINARY(4))

Returns

  0x8075726F

On my default collation.

Edit. Just noticed the Unicode tag

SELECT CAST(N'€uro' AS VARBINARY(8))

Returns

 0xAC20750072006F00
like image 120
Martin Smith Avatar answered Nov 09 '22 04:11

Martin Smith