sqlsql-servertypes

Difference between numeric, float and decimal in SQL Server


What are the differences between numeric, float and decimal datatypes and which should be used in which situations?

For any kind of financial transaction (e.g. for salary field), which one is preferred and why?


Solution

  • use the float or real data types only if the precision provided by decimal (up to 38 digits) is insufficient

    so generally choosing Decimal as your data type is the best bet if


    1. Exact Numeric Data Types decimal and numeric - MSDN
    1. Approximate Numeric Data Types float and real - MSDN

    Exact Numeric Data Types Approximate Numeric Data Types

    main source : MCTS Self-Paced Training Kit (Exam 70-433): Microsoft® SQL Server® 2008 Database Development - Chapter 3 - Tables, Data Types, and Declarative Data Integrity Lesson 1 - Choosing Data Types (Guidelines) - Page 93