Previous Topic

Next Topic

Inhoudsopgave

Book Index

IntToHex / HexToInt

IntToHex( integer_expression ) / HexToInt( hex_string )

IntToHex returns the hexadecimal equivalent of the integer_expression without leading ‘0x’. HexToInt returns the integer equivalent of a hexadecimal string (with or without the ‘0x’ prefix).

Example

select IntToHex( 15 ) -- returns 0000000F

select HexToInt( ‘0x0F’ ) -- returns 15

Differences

These functions do not exist in MS SQL Server. However, the following statements are their equivalent.

-- equivalent of IntToHex( 15 ), returns 0x0000000F

select convert(binary(4), 15)

-- equivalent of HexToInt( '0x0F' )

select convert(int, 0x0F)