Avatar of ken hanse
ken hanse
Flag for Australia asked on

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?
Microsoft SQL Server 2005Microsoft SQL ServerMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
DBAduck - Ben Miller

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike Eghtebas

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Arifhusen Ansari

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.
SOLUTION
Peter Chan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Scott Pletcher

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
DBAduck - Ben Miller

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ão

ken hanse, do you still need help with this question?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SOLUTION
DBAduck - Ben Miller

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.