SQL Server DWT Function
Updated 2023-11-09 19:05:11.673000
Description
Use the scalar function DWT to convert from drams, grains, grams, hundredweights, ounces, pennyweights, pounds, stones, tonnes, tons, troy pounds or troy ounces to pennyweights.
Syntax
SELECT [westclintech].[wct].[DWT] (
<@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 pennyweights:
| column 1 | column 2 |
|---|---|
| grains | 0.0416666667 |
| drams | 1.13932292 |
| ounces avoirdupois | 18.2291667 |
| pounds avoirdupois | 291.666667 |
| stones | 4083.333338 |
| hundredweights | 29166.6667 |
| tons | 583333.334 |
| pennyweights | 1 |
| ounces troy | 20 |
| pounds troy | 240.0000000 |
| grams | 0.643014931 |
| tonnes | 643014.931 |
Conversion of grams includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.
Examples
select wct.DWT(100, 'lbs');
Here is the result set.
| column 1 |
|---|
| 29166.6667 |