数据库

img qiubolecn

mssql中十进制转换成十六进制字符串

发表于2004/12/29 22:54:00  1561人阅读


ALTER  function IntToHex(@i int)
returns varchar(20)
as
begin
declare @tmpint int

set @tmpint = @i
declare @result varchar(20)
set @result = ''

while @i <> 0
begin
  set @tmpint = @i % 16
  set @i = @i / 16

  set @result = case @tmpint when 15 then 'F' when 14 then 'E' when 13 then 'D'
                when 12 then 'C' when 11 then 'B' when 10 then 'A'
                else ltrim(rtrim(str(@tmpint)))
                end
                + @result

end


return @result
end

阅读全文
0 0

相关文章推荐

img
取 消
img