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
 General SQL Server Forums
 New to SQL Server Programming
 Diff between Numeric and Decimal

Author  Topic 

raky
Aged Yak Warrior

767 Posts

Posted - 2008-04-12 : 02:11:41

Hi, I need to know the difference between Numeric and Decimal datatypes. In which we case we use numeric and in which case we use decimal? I searched in some sql related websites and came to know that both are same. Then what is the need of these two datatypes? Either Numeric or Decimal is alone enough? Please explain me in detail ....
Awaiting your replies...

Thanks,
Rakesh.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-12 : 04:09:44
previously discussed :-
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57498
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-04-15 : 08:11:57
Hi
Both r same,just for use as a synonym.If u refer a sql book,u can read about this..
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-05-02 : 10:02:46
Hi,

Verify this

Decimal and numeric variables are functionally equivalent and store numbers of fixed precision and scale.

Precision indicates the maximum number of digits that may be stored (including those before and after the

decimal point. Scale indicates the number that may be stored to the right of the decimal point.

Money
Variables store 8-byte currency values ranging from -922,337,203,685,477.5808 to 922,337,203,685,477.5807. They may reflect any currency type.

In Brief

Numeric Data
Numeric data consists of numbers only. Numeric data includes positive and negative numbers, decimal and fractional numbers, and whole numbers (integers).
Integer Data
Integer data consists of negative or positive whole numbers, such as -15, 0, 5, and 2509. Integer data is stored using the bigint, int, smallint, and tinyint data types in Microsoft® SQL Server™ 2000. The bigint data type can store a larger range of numbers than the int data type. The int data type can store a larger range of integers than smallint, which can store a larger range of numbers than tinyint.
Use the bigint data type to store numbers in the range from -2^63 (-9223372036854775808) through 2^63-1 (9223372036854775807). Storage size is 8 bytes.
Use the int data type to store numbers in the range from -2,147,483,648 through 2,147,483,647 only (requires 4 bytes of storage per value).
Use the smallint data type to store numbers in the range from -32,768 through 32,767 only (requires 2 bytes of storage per value), and the tinyint data type to store numbers in the range from 0 through 255 only (requires 1 byte of storage per value).
Decimal Data
Decimal data consists of data that is stored to the least significant digit. Decimal data is stored using decimal or numeric data types in SQL Server. The number of bytes required to store a decimal or numeric value depends on the total number of digits for the data and the number of decimal digits to the right of the decimal point. For example, more bytes are required to store the value 19283.29383 than to store the value 1.1.
In SQL Server, the numeric data type is equivalent to the decimal data type.

Money data
Monetary data represents positive or negative amounts of money. In Microsoft® SQL Server™
2000, monetary data is stored using the money and small money data types. Monetary data can be
stored to an accuracy of four decimal places. Use the money data type to store values in the range
from -922,337,203,685,477.5808 through +922,337,203,685,477.5807 (requires 8 bytes to store a
value). Use the small money data type to store values in the range from -214,748.3648 through
214,748.3647 (requires 4 bytes to store a value). If a greater number of decimal places are
required, use the decimal data type instead.


Be cool
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-05-02 : 11:09:52
quote:
Originally posted by raky
Please explain me in detail ....




We probably would need a picture to do that...

Damn, 11k on a useless post



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -