declare @a money
set @a=123456789.123
select convert(varchar(20),@a,1)
123,456,789.12
小数点只能两位,三位只好你自已写函数了。

解决方案 »

  1.   

    使用 CONVERT:
    在下表中,左列表示从 money 或 smallmoney 转换为字符数据时的 style 值。值             输出 
    0(默认值)   小数点左侧每三位数字之间不以逗号分隔,小数点右侧取两位数,
                  例如 4235.98。 
    1             小数点左侧每三位数字之间以逗号分隔,小数点右侧取两位数,
                  例如 3,510.92。 
    2             小数点左侧每三位数字之间不以逗号分隔,小数点右侧取四位数,
                  例如 4235.9819。  
      

  2.   

    函数:create function fn_FormatNumber(@n numeric(18,4))
    returns varchar(30)
    as
    begin
       declare @t varchar(30)
       set @t=cast(@n as varchar(30))
       while right(@t,1)='0' 
          set @t=left(@t,len(@t)-1)
       
       declare @i int
       set @i=charindex('.',@t)
       if @i=0
    set @i=len(@t)
       else
    set @i=@i-1
       while @i>3
       begin
          set @t=left(@t,@i-3)+','+right(@t,len(@t)-@i+3)
          set @i=@i-3
       end
       if right(@t,1)='.'
    set @t=left(@t,len(@t)-1)
       return  @t
    end调用:
    select dbo.fn_FormatNumber(123456789.123)