Apr 21, 2012

Identity column with decimal datatype

 "Is decimal point allowed in the identity column?" .

The identity column can never have any decimal points. It is a whole number. The decimal datatype can be used to have a bigger number in the identity column as decimal can have maximum of 38 digits.
The following are the code to create an identity column with decimal datatype

1 Specify scale as 0

           declare @t table(i decimal(38,0) identity(1,1))
           insert into @t default values
           select * from @t

2 Omit scale part

        declare @t table(i decimal(38) identity(1,1))
        insert into @t default values
        select * from @t

No comments:

Post a Comment


Thanks for your visit to this blog.
We would be happy with your Queries/Suggestions.