日期:2014-05-17 浏览次数:20519 次
CREATE function HEXTODEC(@s VARCHAR(255) ) --十六进制转化为十进制 returns int as BEGIN DECLARE @i int, @temp char(1), @result int SELECT @i=1 SELECT @result=0 WHILE (@i<=LEN(@s)) BEGIN SELECT @temp=UPPER(SUBSTRING(@s,@i,1)) IF (@temp>='0') AND (@temp<='9') SELECT @result=@result+ (ASCII(@temp)-48)*POWER(16,LEN(@s)-@i) ELSE IF (@temp>='A') AND (@temp<='F') SELECT @result=@result+ (ASCII(@temp)-55)*POWER(16,LEN(@s)-@i) SELECT @i=@i+1 END return @result END
------解决方案--------------------
帮顶。