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

  • 相关阅读:
    HTTP状态码
    firefox浏览器新建页面一直处于刷新状态解决方法
    firefox浏览器需要新建窗口时以新建标签页代替
    bash基础教程
    sqoop的导入|Hive|Hbase
    sqoop导出数据|Hive|HDFS和脚本编写
    sqoop安装
    sqoop简介和原理分析
    Oozie安装
    Oozie框架介绍
  • 原文地址:https://www.cnblogs.com/hzf08/p/6400435.html
Copyright © 2011-2022 走看看