Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare integer numric

Status
Not open for further replies.

baran121

Programmer
Sep 8, 2005
337
TR
hi everybody,

i wanna learn which is better to use ?

my data will be maximum 4 digit
so numeric(4) or smallint . which one i should use?

is there any good article about it.

thank you.

 
Smallint - 2 bytes
Numeric(4) - 5 bites
:)

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
so i should use numeric(4)
thank you very much.
 
Hey Boris,

Is that a typo... BOL says

numeric[ (p[ , s] )]
Fixed precision and scale numbers. When maximum precision is used, valid values are from - 10^38 +1 through 10^38 - 1.

Precision Storage bytes
1 - 9 5

Simi


 
The most important thing to consider is the type of numbers you will store. Will any have decimal places? If so you can't use the INT data type (including SMALLINT and BIGINT).

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
What typo?
precision 4 - 5 bites :)

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Here's the proof:

Code:
Declare @NumericVariable Numeric(4)
Set @NumericVariable = 0
Select DATALENGTH(@NumericVariable)

Declare @SmallIntVariable SmallInt
Set @SmallIntVariable = 0
Select DATALENGTH(@SmallIntVariable)


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top