Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

hex string sql becomes int64

CREATE TEMP FUNCTION
  hex64ToInt64(hex STRING)
  RETURNS INT64 AS (
    IF(hex < "8000000000000000", 
       cast(concat("0x", hex) AS INT64), 
       (SELECT (((ms32 & 0x7fffffff) << 32) | ls32) - 0x7fffffffffffffff - 1
        FROM (SELECT cast(concat("0x", substr(hex, 1, 8)) AS INT64) AS ms32,
                     cast(concat("0x", substr(hex, 9, 8)) AS INT64) AS ls32))));
Source by blog.0101010.com #
 
PREVIOUS NEXT
Tagged: #hex #string #sql
ADD COMMENT
Topic
Name
6+1 =