Logo

SQL Server GRAINS Function

Updated 2023-11-09 19:06:11.260000

Description

Use the scalar function GRAINS to convert from drams, grains, grams, hundredweights, ounces, pennyweights, pounds, stones, tonnes, tons, troy pounds or troy ounces to grains.

Syntax

SELECT [westclintech].[wct].[GRAINS] (
  <@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 grains:

column 1column 2
grains1
drams27.34375
ounces avoirdupois437.5
pounds avoirdupois7000
stones98000
hundredweights700000
tons14000000
pennyweights24
ounces troy480
pounds troy5760
grams15.4323584
tonnes15432358.4

Conversion of grams includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.

Examples

select wct.GRAINS(100, 'lbs');

Here is the result set.

column 1
700000