Identity Column with int, bigint, and decimal(38,0)

 create table test (tid decimal(38,0) identity(9223372036854775805,1),col1 varchar(10))
insert into test values('a1'),('a2'),('a3'),('a4'),('a5'),('a6')

select tid, col1 from test

select cast(9223372036854775807 as bigint) --works
--select cast(9223372036854775808 as bigint) -- error 

select cast(replicate('9',38) as decimal(38,0)) [the largest number in SQL Server] 

drop table test

-2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
-2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)

-2^15 (-32,768) to 2^15-1 (32,767)

0 to 255

The decimal can go up to 10^38 - 1 with decimal (38,0)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s