SQL Server CONVERTWEIGHT Function
Updated 2024-02-13 19:19:13.390000
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.
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 Type
float
Remarks
Weight unit representations:
| 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 |
Examples
select wct.CONVERTWEIGHT(16, 'oz', 'g');
Here is the result set.
| column 1 |
|---|
| 453.59232 |