DEC2OCT
Updated 2023-11-08 16:04:02.333000
Syntax
SELECT [westclintech].[wct].[DEC2OCT] (
<@Number, float,>
,<@Places, float,>)
Description
Use the scalar function DEC2OCT to convert a decimal number to octal.
Arguments
@Places
The number of characters to use. If @Places is NULL, DEC2OCT 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 decimal integer you want to convert. If @Number is negative, valid @Places values are ignored and DEC2OCT returns a 10-character (30-bit) octal number in which the most significant bit is the sign bit. The remaining 29 bits are magnitude bits. Negative numbers are represented using two's-complement notation. @Number is an expression of type float or of a type that can be implicitly converted to float.
Return Type
nvarchar(4000)
Remarks
If @Number is less than -536,870,912 or @Number is greater than 536,870,911, DEC2OCT returns an error.
If @Number is negative, DEC2OCT ignores places and returns a 10-character octal number.
@Places is truncated to zero decimal places.
Examples
select wct.DEC2OCT(-512, NULL);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"7777777000"}]}
select wct.DEC2OCT((power(8.0000, 10.0000) / 2) - 1, NULL);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"3777777777"}]}
select wct.DEC2OCT(100, 10);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0000000144"}]}