2014-08-18

TSQL - Format numbers with commas, no decimal digits

select
       replace(
                     CONVERT(varchar, CAST(round( [FIELD NAME HERE] ,0) AS money), 1)
                     , '.00'
                     , ''
              )
       );



Function:

ALTER function [dbo].[getCommas](
       @value as float
)
returns varchar(50)
as
begin

       return(
              replace(
                     CONVERT(varchar, CAST(round(@value,0) AS money), 1)
                     , '.00'
                     , ''
              )
       );

end
;


No comments:

Post a Comment