Share via


int data type storing 11 digit ??

Question

Wednesday, June 12, 2013 9:34 AM

hi all

  this is very basic question,i create table with int column, how digit i can store in int, its allowing 11 digit, how its working please anyone can explain me ??

Thanks in advance.

All replies (8)

Wednesday, June 12, 2013 9:45 AM ✅Answered

INTEGER or INT - A 32-bit signed integer value. The range of INTEGER is -2147483648 to 2147483647. 

Try the below:

Select Power(cast(2 as varchar),(32) -1)-1 as 'int max range'  from sys.types Where name = 'Int' 

Declare @int int =2147483647

Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


Wednesday, June 12, 2013 9:48 AM ✅Answered

Hi,

Int stores Integer (whole number) data from -2^31 (-2,147,483,648) through 2^31 - 1 (2,147,483,647).

They are stored as signed 32-bit (4-byte) integers

Thanks & Regards RAJUKIRAN L Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers.


Wednesday, June 12, 2013 9:57 AM ✅Answered

here its accepting 11 digits.

create table test
(
id int
)

insert into test values(01234567891)

Check the value by selecting the table also...Int ignores the '0's prefixed....

create table test
(
id int
)

insert into test values(01234567891)

Select * From test --1234567891

Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


Wednesday, June 12, 2013 9:48 AM

Please post table DDL and example of "11" digit INT.  You get an arithmetic overflow error when trying to insert 2147483648 (max being 2147483647), so 11 digits isn't going to work....

Thanks, Andrew


Wednesday, June 12, 2013 9:52 AM

here its accepting 11 digits.

create table test
(
id int
)

insert into test values(01234567891)

Wednesday, June 12, 2013 9:56 AM

01234567891=1234567891

Thanks, Andrew


Thursday, June 13, 2013 7:25 AM

Hi Selva.

SQL automatically truncates the prefix 0s. So basically 01234567891 is equivalent to 123456789


Thursday, June 13, 2013 8:20 AM

Hi Selva.

SQL automatically truncates the prefix 0s. So basically 01234567891 is equivalent to 123456789

A typo: 

SQL automatically truncates the prefix 0s. So basically 01234567891 is equivalent to 1234567891

Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.