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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 decimal vs numeric?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SQLServerDBA_Dan
Aged Yak Warrior

USA
752 Posts

Posted - 11/09/2005 :  08:29:55  Show Profile  Reply with Quote
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

India
22864 Posts

Posted - 11/09/2005 :  08:33:18  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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

Slovenia
11752 Posts

Posted - 11/09/2005 :  08:34:36  Show Profile  Visit spirit1's Homepage  Reply with Quote
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

USA
752 Posts

Posted - 11/09/2005 :  08:45:16  Show Profile  Reply with Quote
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.

Edited by - SQLServerDBA_Dan on 11/09/2005 08:47:16
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11752 Posts

Posted - 11/09/2005 :  09:10:35  Show Profile  Visit spirit1's Homepage  Reply with Quote
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

Edited by - spirit1 on 11/09/2005 09:10:53
Go to Top of Page

SQLServerDBA_Dan
Aged Yak Warrior

USA
752 Posts

Posted - 11/09/2005 :  09:14:42  Show Profile  Reply with Quote
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

USA
752 Posts

Posted - 11/09/2005 :  09:20:09  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000