Login     Register

        Contact Us     Search

XLeratorDB/engineering Online Documentation

SQL Server OCT2HEX function


 
Updated: 27 August 2010

Use OCT2HEX to convert an octal number to hexadecimal.
Syntax
SELECT [wctEngineering].[wct].[OCT2HEX] (
   <@Number, nvarchar(4000),>
 ,<@Places, float,>)
Arguments
@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
@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
Return Types
varchar(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
-----------------------------
00000036
 
(1 row(s) affected)


select
wct.OCT2HEX(766,8)

This produces the following result
-----------------------------
000001F6
 
(1 row(s) affected)


select
wct.OCT2HEX(7777777000,NULL)

This produces the following result
-----------------------------
FFFFFFFE00
 

(1 row(s) affected)



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service