declare @num int=79,@rm varchar(50),@temp varchar(50)='',@c varchar(100),@hold int
set @hold=@num;
if(@num=0)
set @temp=@num
print @temp
while(@num>0)
begin
set @rm=@num%16;
set @num=@num/16;
set @c=(case when @rm=10 then 'A' when @rm=11 then 'B'when @rm=12 then 'C' when @rm=13 then 'D'
when @rm=14 then 'E' when @rm=15 then 'F' else @rm end)
set @temp=CAST(@c as varchar)+CAST(@temp as varchar)
end
select CAST(@hold as varchar)'Decimal',@temp'Hexadecimal'
you can see the slide with output
set @hold=@num;
if(@num=0)
set @temp=@num
print @temp
while(@num>0)
begin
set @rm=@num%16;
set @num=@num/16;
set @c=(case when @rm=10 then 'A' when @rm=11 then 'B'when @rm=12 then 'C' when @rm=13 then 'D'
when @rm=14 then 'E' when @rm=15 then 'F' else @rm end)
set @temp=CAST(@c as varchar)+CAST(@temp as varchar)
end
select CAST(@hold as varchar)'Decimal',@temp'Hexadecimal'
you can see the slide with output
No comments :
Post a Comment