Login     Register

        Contact Us     Search

XLeratorDB/strings Online Documentation

SQL Server FIXED function


FIXED

Updated: 30 April 2009

Use FIXED to format a number in decimal format using a period and commas, round the number to the specified number of decimals, and return the result as text.
Syntax
SELECT [wctString].[wct].[FIXED] (
   <@Number, float,>
 ,<@Decimals, int,>
 ,<@No_commas, bit,>)
Arguments
@Number
the number to be evaluated. The @Number argument can be an expression of types that are implicitly convertible to float.
 
@Decimals
is the number of decimal places in the result. The @Decimals argument can be an expression of types that are implicitly convertible to int.
 
@No_commas
is the number of decimal places in the result. The @No_commas argument can be an expression of types that are implicitly convertible to bit.
 
Return Types
nvarchar(4000)
Remarks
·         Set @No_commas = 1 to return no commas.
·         If @Decimals < 0, then @Number is rounded to the left of the decimal.
Examples
 
select wct.fixed(100, 5,0)
UNION
select wct.fixed(1000, 5,0)
UNION
select wct.fixed(10000, 5,0)
order by 1
 
This produces the following result
-------------------------------------------------------------------------------
1,000.00000
10,000.00000
100.00000
 
(3 row(s) affected)
 


select
wct.fixed(1234567890, -3, 1)
 
This produces the following result
------------------------------------------------------------------------------
1234568000
 

(1 row(s) affected)



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service