Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 decimal vs numeric?

Author  Topic 

SQLServerDBA_Dan
Aged Yak Warrior

752 Posts

Posted - 2005-11-09 : 08:29:55
Why would one choose decimal over numeric? Lets assume this is a new database and none of the tables have been defined yet.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-09 : 08:33:18
Read the difference between them in Books On Line, SQL Server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-09 : 08:34:36
from BOL

decimal and numeric:
decimal
- Fixed precision and scale numeric data from -10^38 +1 through 10^38 1.

numeric
- Functionally equivalent to decimal.


so whatever you like best. i use decimal... more intuitive.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

SQLServerDBA_Dan
Aged Yak Warrior

752 Posts

Posted - 2005-11-09 : 08:45:16
quote:
Originally posted by madhivanan

Read the difference between them in Books On Line, SQL Server help file

Madhivanan

Failing to plan is Planning to fail



Spirit1 beat me to it. Lol. Of course I checked BOL before posting. They're the same! I just didnt know if one came first and would be phased out in a future version of SQL Server. I figured one was there because they carried over from sybase.

edit: And the fact that they are the same is where my problem comes from. Why have both. I understand the need for redundancy but not for datatypes.

Thanks.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-09 : 09:10:35
http://www.intelligententerprise.com/000626/celko.jhtml
gives this:

The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the
SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as
declared, while NUMERIC(s,p) must be at least as precise as declared.
The Sybase and SQL Server family treats them the same.
...
NUMERIC(s,p) looks like the Oracle proprietary NUMBER(s,p)
declarations.


but why have both... beats me...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

SQLServerDBA_Dan
Aged Yak Warrior

752 Posts

Posted - 2005-11-09 : 09:14:42
I found this comment on codeproject and I'll take it as an answer.

"On SQL Server, decimal and numeric are one and the same. My guess is that numeric came first, and when the SQL-92 standard came around, which uses the name decimal for the same kind of type, SQL Server adopted it as a synonym."

Thanks.
Go to Top of Page

SQLServerDBA_Dan
Aged Yak Warrior

752 Posts

Posted - 2005-11-09 : 09:20:09
quote:
Originally posted by spirit1

http://www.intelligententerprise.com/000626/celko.jhtml
gives this:

The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the
SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as
declared, while NUMERIC(s,p) must be at least as precise as declared.
The Sybase and SQL Server family treats them the same.
...
NUMERIC(s,p) looks like the Oracle proprietary NUMBER(s,p)
declarations.


but why have both... beats me...

Go with the flow & have fun! Else fight the flow



Thanks for the article that was pretty good. My favorite line was:
"The moron that declared columns to be FLOAT in a commercial system is probably a C programmer who does not understand rounding errors"
Go to Top of Page
   

- Advertisement -