SQL Server CWT Function
Updated 2023-11-09 19:02:46.793000
Description
Use the scalar function CWT to convert from drams, grains, grams, hundredweights, ounces, pennyweights, pounds, stones, tonnes, tons, troy pounds or troy ounces to hundredweights.
Syntax
SELECT [westclintech].[wct].[CWT] (
<@Weight, float,>
,<@From_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.
Return Type
float
Remarks
The following table is a representation of the conversion of one of the weight units of measure into hundredweights:
| column 1 | column 2 |
|---|---|
| grains | 0.000001428571 |
| drams | 3.90625E-05 |
| ounces avoirdupois | 0.000625 |
| pounds avoirdupois | 0.01 |
| stones | 0.14 |
| hundredweights | 1 |
| tons | 20 |
| pennyweights | 3.42857E-05 |
| ounces troy | 0.000685714 |
| pounds troy | 0.0082286 |
| grams | 0.00002204622620 |
| tonnes | 22.0462262 |
Conversion of grams includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.
Examples
select wct.CWT(100, 'lbs');
Here is the result set.
| column 1 |
|---|
| 1 |