HiveBrain v1.2.0
Get Started
← Back to all entries
gotchasqlModerate

datatypes in sql server , difference between similar dataypes, numeric, money , decimal ,float

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
moneydataypesnumericsqlfloatdecimaldatatypesdifferencebetweenserver

Problem

What datatypes could be given to this value --> 45.58

Could these be given:

  • numeric



  • money



  • decimal



  • float



What's the difference then? Which one would be the best to use?

Solution

Like everything else in SQL Server, it depends.

Numeric is the same as Decimal. These let you specify precision and are good if you will be having more than 2 decimal places or need more precision than what you indicated.

Money is used for, you guessed it, money. If your field is a currency this is appropriate.

Float is kind of special and is NOT suited for exact numbers. If you need to represent floating point numbers, this is a way to go. If you need to always store exactly what you put in the field, float is a bad choice.

So, what do you want to use the field for? What does your data actually represent? That should be the determining factor in what datatype you use.

Context

StackExchange Database Administrators Q#12916, answer score: 11

Revisions (0)

No revisions yet.