SqlServer 存储过程怎么写呢?

解决方案 »

  1.   

    0  48
    1  49
    2  50
    .
    .
    .
    .
    .
    .
    .. 65
    我是这样子简单计算的,17比1多16,所以49+16=65。ASCLL码表里面有详细的转码表的
      

  2.   


    create table ascll(a varchar(10),b varchar(10))
    如 a =41 b=65  create proc test
    @info nvarchar(100)
    as
    begin
    declare @value nvarchar(100)
    declare @int int
    set @value=''
    set @int=0
    while @int<LEN(@info)
    begin
    set @value=@value+(select b from ascll where a=substring(@info,@int,2))
    set @int=@int+2
    end
    select @value
    end
    差不多就这样了  自己改改
      

  3.   


    create proc test
    @info nvarchar(100)
    as
    begin
    declare @value nvarchar(100)
    declare @int int
    set @value=''
    set @int=0
    while @int<LEN(@info)
    begin
    set @value=@value+char((select b from ascll where a=substring(@info,@int,2)))
    set @int=@int+2
    end
    select @value
    end
      

  4.   

    while @int<(LEN(@info)-2) 在while循环后面 @value单独加  @value=@value+char(20)  
      

  5.   

    执行存储过程,输入参数时,出现报错消息 248,级别 16,状态 1,过程 test,第 9 行
    转换 nvarchar 值 '414231323334353637383920' 时溢出了整数列。
      

  6.   


    create table ascll(a varchar(10),b varchar(10))
    insert ascll
    select '30','48' union all 
    select '31','49' union all 
    select '32','50' union all 
    select '33','51' union all 
    select '34','52' union all 
    select '35','53' union all 
    select '36','54' union all 
    select '37','55' union all 
    select '38','56' union all 
    select '39','57' union all 
    select '41','65' union all 
    select '42','66'create proc test
    @info nvarchar(100)
    as
    begin
    declare @value nvarchar(100)
    declare @int int
    set @value=''
    set @int=1
    while @int<(LEN(@info)-1)
    begin
    set @value=@value+char((select TOP 1 b from ascll where a=substring(@info,@int,2)))
    set @int=@int+2
    end
    select @value
    end
    /*
    exec test 
    @info='414231323334353637383920'
    AB123456789
    */