20000.00 
154248.25 要求输出格式为17位不带小数点 
00000000002000000 
00000000015424825 有人推荐
select right('0000000000'+ltrim(金额*100),17) from tb
但无法实现请指点哈,急用

解决方案 »

  1.   

    select right('00000000000000000'+ltrim(金额*100),17) from tb 有什么问题??
      

  2.   


    --可以啊
    declare @a numeric,@b numericset @a = 20000.00
    set @b = 154248.25 print   right('0000000000'+ltrim(@a*100),17) 
    print    right('0000000000'+ltrim(@b*100),17) 
      

  3.   

    select right('0000000000'+ltrim(金额*100),17) from tb --17是总位数.
      

  4.   

    select right(REPLICATE('0',17)+ltrim(金额*100),17) from tb --17是总位数.
      

  5.   

    select right('00000000000000000000000000'+ltrim(金额*100),17) from tb 
      

  6.   

    create table tb(id decimal(18,2))
    insert into tb values(20000.00) 
    insert into tb values(154248.25)
    goselect right('0000000000000000' + cast(cast(id*100 as int) as varchar),17) from tb
    /*
    ---------------------------------- 
    00000000002000000
    00000000015424825(所影响的行数为 2 行)
    */select right('0000000000000000' + ltrim(cast(id*100 as int)),17) from tb
    /*
    ---------------------------------- 
    00000000002000000
    00000000015424825(所影响的行数为 2 行)
    */drop table tb