Hexadecimal Constants in Oracle - Oracle to SQL Server Migration

In Oracle, you can use TO_NUMBER function with x format to represent a hex constant (literal). In SQL Server, you can use the prefix 0x followed by hexadecimal digits.

Oracle:

  -- Represent the hexadecimal constant ABC and use it in an expression
  SELECT TO_NUMBER('ABC', 'xxx') + 10 FROM dual;

SQL Server:

  -- Represent the hexadecimal constant ABC and use it in an expression
  SELECT 0xABC + 10;

Resources

Oracle 11g R2 SQL Language Reference

Microsoft SQL Server 2012 - Books Online

You could leave a comment if you were logged in.