zoukankan      html  css  js  c++  java
  • 存储过程实现10进制和N(2<=N<=36)的转换

    参考博文:http://www.cnblogs.com/wghao/p/6381865.html

    实现了N进制转换的过程:

    过程代码如下:


    /*
    declare @outres varchar(1024)
    exec T10TOTN 110,@outres output,11
    select @outres
    */

    alter procedure T10TOTN(
    @input_int int,
    @output varchar(1024) output,
    @N_int int
    )
    as
    begin

    set @output = ''
    if 1 < @N_int and @N_int <= 10 begin
    while(1=1) begin
    select @output = convert(varchar(1024), @input_int%@N_int) + @output, @input_int = @input_int/@N_int;
    if @input_int = 0 break;
    end;
    return;
    end
    if @N_int > 10 and @N_int <36 begin
    declare @tb_tmp as table(id int identity(0,1) primary key,radix char(1))
    ;with cte as (select top (@N_int) row_number() over(order by getdate())-1 as id from sys.columns)
    insert into @tb_tmp(radix)
    select case when id>9 then char(55+id) else rtrim(id) end as radix from cte where char(55+id) not in ('I','O','U')
    while(1=1) begin
    select @output = convert(varchar(1024),(select radix from @tb_tmp where id = @input_int%@N_int)) + @output, @input_int = @input_int/@N_int;
    if @input_int = 0 break;
    end;
    return;
    return;
    end
    return;
    end

  • 相关阅读:
    angular2 + bootstrap +jquery 实例
    How to create a angular2 project process
    icheck 插件
    select2 下面的搜索框 无法输入问题
    datatabels buttons
    datatables 跳转到指定页
    text-overflow:ellipse;
    box-shadow
    CSS强制性换行
    mybatis与hibernate的不同
  • 原文地址:https://www.cnblogs.com/hzf08/p/6400435.html
Copyright © 2011-2022 走看看