Logo

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:

grainsgr, grain, grains
dramsdr, dram, drams
ounces avoirdupoisoz, ozs, ounce, ounces
pounds avoirdupoislb, lbs, pound, pounds
stonesstone, stones
hundredweightscwt, hundredweight, hundredweights
tonston, tons
pennyweightsdwt, pennyweight, pennyweights
troy ouncesoz t, troy ounce, troy ounces
troy poundslb t, troy pound, troy pounds
gramsg, gram, grams,
decigramsdg, decigram, decigrams,
centigramscg, centigram, centigrams,
milligramsmg, milligram, milligrams,
microgramsµg, microgram, micrograms,
nanogramsng, nanogram, nanograms,
picogramspg, picogram, picograms,
femtogramsfg, femtogram, femtograms,
attogramsag, attogram, attograms,
zeptogramszg, zeptogram, zeptograms,
yoctogramsyg, yoctogram, yoctograms,
decagramsdag, decagram, decagrams,
hectogramshg, hectogram, hectograms,
kilogramskg, kilogram, kilograms
tonnest, tonne, tonnes

Examples

select wct.CONVERTWEIGHT(16, 'oz', 'g');

Here is the result set.

column 1
453.59232