您的位置:首页 > 数据库

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

2004-12-29 22:54 381 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: