cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a hexadecimal string to BIGINT on SA10

Former Member
3,828

The title says it all. HEXTOINT can only convert integers up to 32 bit. I need to convert a 48 bit-long number from hex to decimal and viceversa.

View Entire Topic
Breck_Carter
Participant
BEGIN
DECLARE @hex VARCHAR ( 100 );
DECLARE @bigint BIGINT;
SET @hex = '7048860DDF79';
EXECUTE IMMEDIATE STRING ( 'SET @bigint = CAST ( 0x', @hex, ' AS BIGINT )' );
SELECT @bigint;
END;

@bigint
123456789012345
Former Member
0 Kudos

Thanks for the fast response!