2015-04-11

TSQL - Format number with commas

/*

       -- Execution
       select dbo.getCommas( 1234.02 );
       select dbo.getCommas( -1234567.99 );


*/
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