ALTER function [dbo].[fn_10to36] ( @i int ) returns varchar(30) as begin
declare @r varchar(30) set @r= ''
declare @m int declare @s int set @s=@i while @s> =36 begin set @m=@s % 36 set @r=case when @m <10 then cast(@m as varchar) else cast(char(ascii( 'A')+@m-10) as varchar) end+@r set @s=@s/36 end if @s> 0 or (@s=0 and @r= '') set @r=case when @s <10 then cast(@s as varchar) else cast(char(ascii( 'A')+@s-10) as varchar) end+@r return @r end