INT vs NUMERIC(10,0)

Hi,

What is the different between INT vs NUMERIC(10,0).

I know INT uses  4 bytes, however, numeric?

Does that link with SQL JOIN or SSIS lookUP without conversion?
ken hanseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
int is the same as numer(38,0)

value = 36.7      integer(value) - 37     number(value)=36.7
value = 36.3      integer(value) - 36     number(value)=36.3

If it is to be used for SQL JOIN, then you need whole number thus int is the correct choice,

NUMERIC(10,0) is whole number also but limited to 10 digits while int being Number(38,0) is whole number with 38 digits space to store your value.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Arifhusen AnsariBusiness Intelligence Developer and AnalystCommented:
Hi,

Answer to you first question that whats the difference between int and numeric (10,0)

Hence you  have used 0 as scale in the numeric type there in no any difference between int and numeric. So difference is only regarding storage of variable. Here int will use 4 bytes and numeric(10,0) will use 9 bytes of storage.
Until and unless you add scale in numeric data type it's same as int. But when we are talking about storage, numeric type storage varies based on the size of precision declared . Numeric (p,s) maximum p is 38 default is 18, if not specified.

Precision  Storage bytes
1 - 9            5
10-19         9
20-28       13
29-38       17

Second Question:
Does it make any difference on join : if you are not storing any data in the scale part of numeric, the answer is no. It won't effect the join.
e.g. int 3 in same as numeric 3.000
      but 3 is not same as 3.11

It doesn't have any issue with the conversion while using is ssis package as well.  if you are storing any numeric data with scale in int it will be rounded of.
e.g numeric 3.44 will be 3 as 3.55 will be 4

You are using numeric with 0 scale, so you won't have any issues.
HuaMin ChenProblem resolverCommented:
Here is the range of int

-2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)

Open in new window


on Sql server, while Max number of Number(10,0) only is 9,999,999,999.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Scott PletcherSenior DBACommented:
A positive int value can only store up to (2 billion - 1), whereas decimal(10,0) can store up to (10B - 1).  As noted above, int is 4 bytes, decimal(10) is 9 bytes.

Int is strongly preferred, because joins with it are more efficient.  If you need more than 2B values, use bigint, which is 8 bytes but doesn't have the more complex structure of a decimal column.

If you join an int to a decimal, the int will have to be converted to decimal, and that will drastically slow down the join.
DBAduck - Ben MillerPrincipal ConsultantCommented:
Here is some good information on the subject. I agree with ScottPletcher and so does this article.

http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-types-numeric-vs-int/
Vitor MontalvãoMSSQL Senior EngineerCommented:
ken hanse, do you still need help with this question?
DBAduck - Ben MillerPrincipal ConsultantCommented:
Here is some more information that indicates that NOT all IMPLICIT_CONVERT operators will show up in query plans.

http://sqlblog.com/blogs/paul_white/archive/2011/07/19/join-performance-implicit-conversions-and-residuals.aspx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.