Login     Register

        Contact Us     Search

XLeratorDB/engineering Online Documentation

SQL Server function to convert weight to grams


GRAMS
 
Updated: 01 December 2008 

Use GRAMS to convert from drams, grains, grams, hundredweights, ounces, pennyweights, pounds, stones, tonnes, tons, troy pounds, or troy ounces to troy pounds.
Syntax
SELECT [westclintech].[wct].[GRAMS] (
  <@Weight, float,>
 ,<@From_scale, nvarchar(4000),>
 ,<@To_scale, nvarchar(4000),>)
Arguments
@Weight
is any real number. @Weight is an expression of type float or of a type that can be implicitly converted to float
@From_scale
is the description of the units for @Weight. @From_scale must be a valid value as specified in weight unit representations@From_scale must be of a data type that is implicitly convertible to varchar.
 
@To_scale
is the description of the units for that @Volume is to be converted into. @To_scale must be a valid value as specified in weight unit representations. In addition to grams, @To_scale  can be decigrams, centigrams, milligrams, micrograms, nanograms, picograms, femtograms, attograms, zeptograms, yoctograms, decagrams, hectograms, or kilograms .@To_scale must be of a data type that is implicitly convertible to varchar.
 
Return Types
float
Remarks
·         The following table is a representation of the conversion of one of the weight units of measure into grams:
grains
0.06479891000
drams
1.7718452
ounces avoirdupois
28.34952
pounds avoirdupois
453.59237
stones
6350.29318
hundredweights
45359.237
tons
907184.74
pennyweights
1.55517384
ounces troy
31.1034768
pounds troy
373.2417216
grams
1
tonnes
1000000
 
·         Conversion of grams includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.
Example
 
select wct.GRAMS(100, 'lbs', 'kg')
Here is the result set
----------------------
45.359237
 
(1 row(s) affected)


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service