Logo

OCT2HEX

Updated 2023-11-08 16:17:40.347000

Syntax

SELECT [westclintech].[wct].[OCT2HEX] (
  <@Number, nvarchar(4000),>
 ,<@Places, float,>)

Description

Use the scalar function OCT2HEX to convert an octal number to hexadecimal.

Arguments

@Places

The number of characters to use. If @Places is NULL, OCT2HEX uses the minimum number of characters necessary. @Places is useful for padding the return value with leading 0s (zeros). @Places is an expression of type float or of a type that can be implicitly converted to float.

@Number

is the octal number you want to convert. @Number cannot contain more than 10 characters. The most significant bit of @Number is the sign bit (30th bit from the right). The remaining 29 bits are magnitude bits. Negative numbers are represented using two's-complement notation. @Number is an expression of type nvarchar or of a type that can be implicitly converted to nvarchar.

Return Type

nvarchar(4000)

Remarks

If @Number is negative, OCT2HEX ignores places and returns a 10-character hexadecimal number.

If @Number is not a valid octal number, OCT2HEX returns an error.

@Places is truncated to zero decimal places.

Examples

select wct.OCT2HEX(66, 8);

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"00000036"}]}
select wct.OCT2HEX(766, 8);

This produces the following result.

{"columns":[{"field":"column 1"}],"rows":[{"column 1":"000001F6"}]}
select wct.OCT2HEX(7777777000, NULL);

This produces the following result.

{"columns":[{"field":"column 1"}],"rows":[{"column 1":"FFFFFFFE00"}]}