SQL int to hex conversion little / big endian format

Using MSSMS, I am trying to execute a request.

SELECT CONVERT(BINARY(16), 14437) 

This leads to:

 0x00000000000000000000000000003865 

But this is what I am looking for:

 0x65380000000000000000000000000000 

I tried using the opposite, but no luck.

 SELECT REVERSE(CONVERT(BINARY(16), 14437)) 
+7
source share
1 answer

I tried using the opposite, but no luck.

REVERSE returns a string. Returning to binary returns the desired results.

 SELECT CONVERT(BINARY(16), REVERSE(CONVERT(BINARY(16), 14437))) 
+9
source

All Articles