(8.0.22)
10進数→16進数
select conv(1,10,16);
select conv(10,10,16);
select conv(16,10,16);
select conv(17,10,16);
16進数→10進数
select conv('1',16,10);
select conv('A',16,10);
select conv('10',16,10);
select conv('11',16,10);
(19c)
10進数→16進数
select to_char(1,'XXXX') from dual;
select to_char(10,'XXXX') from dual;
select to_char(16,'XXXX') from dual;
select to_char(17,'XXXX') from dual;
16進数→10進数
select to_number('1','XXXX') from dual;
select to_number('A','XXXX') from dual;
select to_number('10','XXXX') from dual;
select to_number('11','XXXX') from dual;
(13)
https://qiita.com/fujii_masao/items/f418e4d4072b965849f7
10進数→16進数
select to_hex(1);
select to_hex(10);
select to_hex(16);
select to_hex(17);
16進数→10進数
select 'x1'::bit(4)::int;
select 'xa'::bit(4)::int;
select 'x10'::bit(8)::int;
select 'x11'::bit(8)::int;
(2019)
http://babydaemons.hatenablog.com/entry/20110523/Convert_Function_HexString_To_Number_In_SQLServer
10進数→16進数
select cast(1 as varbinary);
select cast(10 as varbinary);
select cast(16 as varbinary);
select cast(17 as varbinary);
16進数→10進数
create or alter function dbo.to_decimal(@input varchar(100) )
returns int
as
begin
declare @len int;
declare @ret int;
declare @i int;
declare @val int;
set @len = len(@input);
set @ret = 0;
set @i = 1;
while @i <= @len
begin
set @val = charindex(lower(substring(@input, @i, 1)), '123456789abcdef')
set @ret = @ret * 16 + @val
set @i = @i + 1
end
return @ret
end
go
select dbo.to_decimal('1');
select dbo.to_decimal('A');
select dbo.to_decimal('10');
select dbo.to_decimal('11');