# SqlDecimal Structure

**.NET Framework 4.5**

Represents a numeric value between - 10^38 +1 and 10^38 - 1, with fixed precision and scale.

**Namespace:**System.Data.SqlTypes

**Assembly:**System.Data (in System.Data.dll)

The SqlDecimal type exposes the following members.

Name | Description | |
---|---|---|

SqlDecimal(Decimal) | Initializes a new instance of the SqlDecimal structure using the supplied Decimal value. | |

SqlDecimal(Double) | Initializes a new instance of the SqlDecimal structure using the supplied double parameter. | |

SqlDecimal(Int32) | Initializes a new instance of the SqlDecimal structure using the supplied integer value. | |

SqlDecimal(Int64) | Initializes a new instance of the SqlDecimal structure using the supplied long integer value. | |

SqlDecimal(Byte, Byte, Boolean, Int32[]) | Initializes a new instance of the SqlDecimal structure using the supplied parameters. | |

SqlDecimal(Byte, Byte, Boolean, Int32, Int32, Int32, Int32) | Initializes a new instance of the SqlDecimal structure using the supplied parameters. |

Name | Description | |
---|---|---|

BinData | Get the binary representation of the value of this SqlDecimal structure as an array of bytes. | |

Data | Gets the binary representation of this SqlDecimal structure as an array of integers. | |

IsNull | Indicates whether this SqlDecimal structure is null. | |

IsPositive | Indicates whether the Value of this SqlDecimal structure is greater than zero. | |

Precision | Gets the maximum number of digits used to represent the Value property. | |

Scale | Gets the number of decimal places to which Value is resolved. | |

Value | Gets the value of the SqlDecimal structure. This property is read-only. |

Name | Description | |
---|---|---|

Abs | The Abs method gets the absolute value of the SqlDecimal parameter. | |

Add | Calculates the sum of the two SqlDecimal operators. | |

AdjustScale | The scale of the SqlDecimal operand will be adjusted to the number of digits indicated by the digits parameter. Depending on the value of the fRound parameter, the value will either be rounded to the appropriate number of digits or truncated. | |

Ceiling | Returns the smallest whole number greater than or equal to the specified SqlDecimal structure. | |

CompareTo(Object) | Compares this SqlDecimal instance to the supplied Object and returns an indication of their relative values. | |

CompareTo(SqlDecimal) | Compares this SqlDecimal instance to the supplied SqlDecimal object and returns an indication of their relative values. | |

ConvertToPrecScale | Adjusts the value of the SqlDecimal operand to the indicated precision and scale. | |

Divide | The division operator calculates the results of dividing the first SqlDecimal operand by the second. | |

Equals(Object) | Compares the supplied Object parameter to the Value property of the SqlDecimal instance. (Overrides ValueType.Equals(Object).) | |

Equals(SqlDecimal, SqlDecimal) | Performs a logical comparison of the two SqlDecimal operands to determine whether they are equal. | |

Floor | Rounds a specified SqlDecimal number to the next lower whole number. | |

GetHashCode | Returns the hash code for this instance. (Overrides ValueType.GetHashCode().) | |

GetType | Gets the Type of the current instance. (Inherited from Object.) | |

GetXsdType | Returns the XML Schema definition language (XSD) of the specified XmlSchemaSet. | |

GreaterThan | Performs a logical comparison of two SqlDecimal structures to determine whether the first is greater than the second. | |

GreaterThanOrEqual | Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is greater than or equal to the second. | |

LessThan | Performs a logical comparison of two SqlDecimal structures to determine whether the first is less than the second. | |

LessThanOrEqual | Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is less than or equal to the second. | |

Multiply | The multiplication operator computes the product of the two SqlDecimal parameters. | |

NotEquals | Performs a logical comparison of the two SqlDecimal parameters to determine whether they are not equal. | |

Parse | Converts the String representation of a number to its SqlDecimal equivalent. | |

Power | Raises the value of the specified SqlDecimal structure to the specified exponential power. | |

Round | Gets the number nearest the specified SqlDecimal structure's value with the specified precision. | |

Sign | Gets a value that indicates the sign of a SqlDecimal structure's Value property. | |

Subtract | Calculates the results of subtracting the second SqlDecimal operand from the first. | |

ToDouble | Returns the a double equal to the contents of the Value property of this instance. | |

ToSqlBoolean | Converts this SqlDecimal structure to SqlBoolean. | |

ToSqlByte | Converts this SqlDecimal structure to SqlByte. | |

ToSqlDouble | Converts this SqlDecimal structure to SqlDouble. | |

ToSqlInt16 | Converts this SqlDecimal structure to SqlInt16. | |

ToSqlInt32 | Converts this SqlDecimal structure to SqlInt32. | |

ToSqlInt64 | Converts this SqlDecimal structure to SqlInt64. | |

ToSqlMoney | Converts this SqlDecimal structure to SqlMoney. | |

ToSqlSingle | Converts this SqlDecimal structure to SqlSingle. | |

ToSqlString | Converts this SqlDecimal structure to SqlString. | |

ToString | Converts this SqlDecimal structure to String. (Overrides ValueType.ToString().) | |

Truncate | Truncates the specified SqlDecimal structure's value to the that you want position. |

Name | Description | |
---|---|---|

Addition | Calculates the sum of the two SqlDecimal operators. | |

Division | The division operator calculates the results of dividing the first SqlDecimal operand by the second. | |

Equality | Performs a logical comparison of the two SqlDecimal operands to determine whether they are equal. | |

Explicit(Double to SqlDecimal) | Converts the Double parameter to SqlDecimal. | |

Explicit(SqlBoolean to SqlDecimal) | Converts the supplied SqlBoolean structure to SqlDecimal. | |

Explicit(SqlDecimal to Decimal) | Converts the SqlDecimal parameter to Decimal. | |

Explicit(SqlDouble to SqlDecimal) | Converts the supplied SqlDouble structure to SqlDecimal. | |

Explicit(SqlSingle to SqlDecimal) | Converts the supplied SqlSingle structure to SqlDecimal. | |

Explicit(SqlString to SqlDecimal) | Converts the supplied SqlString parameter to SqlDecimal. | |

GreaterThan | Performs a logical comparison of two SqlDecimal structures to determine whether the first is greater than the second. | |

GreaterThanOrEqual | Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is greater than or equal to the second. | |

Implicit(Decimal to SqlDecimal) | Converts the Decimal value to SqlDecimal. | |

Implicit(Int64 to SqlDecimal) | Converts the supplied Int64 structure to SqlDecimal. | |

Implicit(SqlByte to SqlDecimal) | Converts the supplied SqlByte structure to SqlDecimal. | |

Implicit(SqlInt16 to SqlDecimal) | Converts the supplied SqlInt16 structure to SqlDecimal | |

Implicit(SqlInt32 to SqlDecimal) | Converts the supplied SqlInt32 structure to SqlDecimal. | |

Implicit(SqlInt64 to SqlDecimal) | Converts the supplied SqlInt64 structure to SqlDecimal. | |

Implicit(SqlMoney to SqlDecimal) | Converts the SqlMoney operand to SqlDecimal. | |

Inequality | Performs a logical comparison of the two SqlDecimal parameters to determine whether they are not equal. | |

LessThan | Performs a logical comparison of two SqlDecimal structures to determine whether the first is less than the second. | |

LessThanOrEqual | Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is less than or equal to the second. | |

Multiply | The multiplication operator computes the product of the two SqlDecimal parameters. | |

Subtraction | Calculates the results of subtracting the second SqlDecimal operand from the first. | |

UnaryNegation | The unary minus operator negates the SqlDecimal parameter. |

Name | Description | |
---|---|---|

MaxPrecision | A constant representing the largest possible value for the Precision property. | |

MaxScale | A constant representing the maximum value for the Scale property. | |

MaxValue | A constant representing the maximum value of a SqlDecimal structure. | |

MinValue | A constant representing the minimum value for a SqlDecimal structure. | |

Null | Represents a DBNull that can be assigned to this instance of the SqlDecimalclass. |

Name | Description | |
---|---|---|

IXmlSerializable.GetSchema | This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. | |

IXmlSerializable.ReadXml | This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. | |

IXmlSerializable.WriteXml | This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. |

SqlDecimal has different underlying data structures from its corresponding .NET Framework Decimal data type. Decimal has no concept of precision. It uses 3 bytes to store the actual data, and therefore has a maximum scale of 28. The data range is -79,228,162,514,264,337,593,543,950,335 through 79,228,162,514,264,337,593,543,950,335. SqlDecimal has both precision and scale. It uses 4 unsigned 4-byte integers to store the actual data, and therefore has maximum precision and scale of 38. The data range is - 10^38 +1 through 10^38 - 1.

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.