Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - Rules on Arithmetic Operations

By: FYIcenter.com

(Continued from previous topic...)

What Are Arithmetic Operators?

An arithmetic operator performs an arithmetic operation on two expressions of numeric data types. SQL Server supports 5 arithmetic operators:

  • + (Add): Addition
  • - (Subtract): Subtraction
  • * (Multiply): Multiplication
  • / (Divide): Division
  • % (Modulo): Modulation

There are several rules on arithmetic operations:

  • Arithmetic operations are performed on expressions of numeric data types like INT, NUMERIC, and FLOAT.
  • When arithmetic operations are performed on expressions of the same data types, no data type conversion is needed.
  • When arithmetic operations are performed on expressions of different data types, implicit data type conversion will be performed before the arithmetic operation on the expression with a lower data type rank.
  • Numeric data type ranks are from low to high: TINYINT, SMALLINT, INT, BIGINT, SMALLMONEY, MONEY, DECIMAL, and FLOAT.
  • The data type of the resulting value of an arithmetic operation is the same as the two input expressions.

(Continued on next topic...)

  1. What Is an Expression?
  2. What Are Arithmetic Operators?
  3. What Happens to an Arithmetic Operation with Two Different Data Types?
  4. How To Convert a Numeric Expression from One Data Type to Another?
  5. How To Convert Numeric Expression Data Types by Assignment Operations?
  6. How To Convert Numeric Expression Data Types using the CAST() Function?
  7. How To Convert Numeric Expression Data Types using the CONVERT() Function?
  8. How To Convert Character Strings into Numeric Values?
  9. What Happens When Converting Big Values to Integers?
  10. What Happens When Converting Big Values to NUMERIC Data Types?
  11. What Are the Mathematical Functions Supported by SQL Server 2005?
  12. How To Convert Numeric Values to Integers?
  13. How To Round a Numeric Value To a Specific Precision?
  14. How To Generate Random Numbers with the RAND() Function?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...