Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Integer datatypes in SQlserver Expand / Collapse
Author
Message
Posted Tuesday, October 14, 2008 1:37 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, April 23, 2014 3:06 PM
Points: 319, Visits: 757
Hi all, I am trying to look up on the size differences between int, bigint and small int. I mostly work with Oracle and i am trying to compare the width of a column between Oracle and SQlserver on how much width the column would need.

Please help. Thanks.
Post #585745
Posted Tuesday, October 14, 2008 1:47 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 6:05 AM
Points: 40,258, Visits: 36,681
Smallint is 2 bytes and stores values between -32768 and 32767
Int is 4 bytes and stores values betweeen -2,147,483,648 and 2,147,483,647
bigint is 8 bytes and stores values between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #585751
Posted Tuesday, October 14, 2008 2:05 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, April 23, 2014 3:06 PM
Points: 319, Visits: 757
Thanks. But application people want to know more about the width rather than the storage size. Like in Oracle we say number(38), it can hold 38 digits.

Thank you
Post #585767
Posted Tuesday, October 14, 2008 2:26 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Friday, October 24, 2014 11:52 AM
Points: 9,294, Visits: 9,484
psangeetha (10/14/2008)
Thanks. But application people want to know more about the width rather than the storage size. Like in Oracle we say number(38), it can hold 38 digits.


Look at Gail's reply and count the number of digits in the answers that she gave you. Do not count the first digit. I do not know if Oracle counts the signs place or not.


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #585785
Posted Tuesday, October 14, 2008 2:26 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 6:05 AM
Points: 40,258, Visits: 36,681
Ints don't have a max number of digits. They have a minimum and maximum value that they can store. As I gave above.

It's the numeric and decimal datatypes that have a max number of digits.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #585786
Posted Tuesday, October 14, 2008 2:29 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Friday, October 24, 2014 11:52 AM
Points: 9,294, Visits: 9,484
psangeetha (10/14/2008)
Thanks. But application people want to know more about the width rather than the storage size. Like in Oracle we say number(38), it can hold 38 digits.


And just in case you do not already know: the equivalent of Number(38) in SQL Server is NUMERIC(38) or DECIMAL(38).


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #585790
Posted Tuesday, October 14, 2008 2:35 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, April 23, 2014 3:06 PM
Points: 319, Visits: 757
Ok Thanks. We are just looking for a datatype we can go with the number of digits.. So the numeric datatype goes with number of digits?? I just tried inserting a record and I think its allowing 18 digits. Please correct me if I am wrong.
If this is correct, we will use number(18) in Oracle.

Thanks.
Post #585795
Posted Tuesday, October 14, 2008 2:41 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 6:05 AM
Points: 40,258, Visits: 36,681
Then you're looking for numeric(18,0)

What did you try inserting and into what datatype?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #585802
Posted Tuesday, October 14, 2008 2:58 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, April 23, 2014 3:06 PM
Points: 319, Visits: 757
I tried below


create table test ( a numeric)
insert into test values (999999999999999999)


This worked.

insert into test values (9999999999999999990) didnt work. So I guess the maximum value for numeric datatype is 18
digits.

Is there any other datatype in SQL server that works with the number of digits and not the min max value?

Thanks.
Post #585824
Posted Tuesday, October 14, 2008 3:15 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Friday, October 24, 2014 11:52 AM
Points: 9,294, Visits: 9,484
The thing is, Oracle does not really have binary integer datatypes the way that SQL does. I think that there may be something like PLS_INTEGER which is equivalent to INTEGER in SQL Server, but that is about it.

This makes for real problems when moving data back and forth. Because the SQL Server Integer sizes are between the decimal sizes that Oracle uses, which size you use depends on whether you are moving data from Oracle to SQL Server or from SQL Server to Oracle. Effectively, the receiver of the data always has to round up the number of digits from the sender.


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #585834
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse