Login     Register

        Contact Us     Search

XLeratorDB/engineering Online Documentation

SQL Server function to convert weight units of measure


CONVERTWEIGHT
 
Updated: 01 December 2008 

Use CONVERTWEIGHT to convert to and from drams, grains, grams, hundredweights, ounces, pennyweights, pounds, stones, tonnes, tons, troy pounds, or troy ounces.
Syntax
SELECT [westclintech].[wct].[CONVERTWEIGHT] (
  <@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 @Weight is being converted from. @From_scale must be a valid value as specified in area unit representations. @From_scale must be of a data type that is implicitly convertible to varchar.
 
@To_scale
is the description of the units @Weight is being converted to. @To_scale must be a valid value as specified in area unit representations. @To_scale must be of a data type that is implicitly convertible to varchar.
 
Return Types
float
Remarks
 
grains
gr, grain, grains
drams
dr, dram, drams
ounces avoirdupois
oz, ozs, ounce, ounces
pounds avoirdupois
lb, lbs, pound, pounds
stones
stone, stones
hundredweights
cwt, hundredweight, hundredweights
tons
ton, tons
pennyweights
dwt, pennyweight, pennyweights
troy ounces
oz t, troy ounce, troy ounces
troy pounds
lb t, troy pound, troy pounds
grams
g, gram, grams,
decigrams
dg, decigram, decigrams,
centigrams
cg, centigram, centigrams,
milligrams
 mg, milligram, milligrams,
micrograms
µg, microgram, micrograms,
nanograms
ng, nanogram, nanograms,
picograms
pg, picogram, picograms,
femtograms
fg, femtogram, femtograms,
attograms
ag, attogram, attograms,
zeptograms
zg, zeptogram, zeptograms,
yoctograms
yg, yoctogram, yoctograms,
decagrams
dag, decagram, decagrams,
hectograms
hg, hectogram, hectograms,
kilograms
kg, kilogram, kilograms
tonnes
t, tonne, tonnes
 
Example
 
select wct.CONVERTWEIGHT(16, 'oz', 'g')
Here is the result set
----------------------
453.59232
 
(1 row(s) affected)


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service