CONVERTWEIGHT
Updated 2024-02-13 19:19:13.390000
Syntax
SELECT [westclintech].[wct].[CONVERTWEIGHT] (
<@Weight, float,>
,<@From_scale, nvarchar(4000),>
,<@To_scale, nvarchar(4000),>)
Description
Use the scalar function CONVERTWEIGHT to convert to and from drams, grains, grams, hundredweights, ounces, pennyweights, pounds, stones, tonnes, tons, troy pounds or troy ounces.
Arguments
@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.
@Weight
is any real number. @Weight is an expression of type float or of a type that can be implicitly converted to float.
@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 Type
float
Remarks
Weight unit representations:
{"columns":[{"field":"grains","width":193},{"field":"gr, grain, grains","width":445}],"rows":[{"grains":"drams","gr, grain, grains":"dr, dram, drams"},{"grains":"ounces avoirdupois","gr, grain, grains":"oz, ozs, ounce, ounces"},{"grains":"pounds avoirdupois","gr, grain, grains":"lb, lbs, pound, pounds"},{"grains":"stones","gr, grain, grains":"stone, stones"},{"grains":"hundredweights","gr, grain, grains":"cwt, hundredweight, hundredweights"},{"grains":"tons","gr, grain, grains":"ton, tons"},{"grains":"pennyweights","gr, grain, grains":"dwt, pennyweight, pennyweights"},{"grains":"troy ounces","gr, grain, grains":"oz t, troy ounce, troy ounces"},{"grains":"troy pounds","gr, grain, grains":"lb t, troy pound, troy pounds"},{"grains":"grams","gr, grain, grains":"g, gram, grams,"},{"grains":"decigrams","gr, grain, grains":"dg, decigram, decigrams,"},{"grains":"centigrams","gr, grain, grains":"cg, centigram, centigrams,"},{"grains":"milligrams","gr, grain, grains":"mg, milligram, milligrams,"},{"grains":"micrograms","gr, grain, grains":"µg, microgram, micrograms,"},{"grains":"nanograms","gr, grain, grains":"ng, nanogram, nanograms,"},{"grains":"picograms","gr, grain, grains":"pg, picogram, picograms,"},{"grains":"femtograms","gr, grain, grains":"fg, femtogram, femtograms,"},{"grains":"attograms","gr, grain, grains":"ag, attogram, attograms,"},{"grains":"zeptograms","gr, grain, grains":"zg, zeptogram, zeptograms,"},{"grains":"yoctograms","gr, grain, grains":"yg, yoctogram, yoctograms,"},{"grains":"decagrams","gr, grain, grains":"dag, decagram, decagrams,"},{"grains":"hectograms","gr, grain, grains":"hg, hectogram, hectograms,"},{"grains":"kilograms","gr, grain, grains":"kg, kilogram, kilograms"},{"grains":"tonnes","gr, grain, grains":"t, tonne, tonnes"}]}
Examples
select wct.CONVERTWEIGHT(16, 'oz', 'g');
Here is the result set.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"453.59232"}]}