what is the use of IDENTITY data type?

  • CREATE TABLE Production.Categories(

    categoryid INT IDENTITY(1,1) NOT NULL,

    categoryname NVARCHAR(15) NOT NULL,

    description NVARCHAR(200) NOT NULL DEFAULT ('')

    )

    This is my create table statement in this [categoryid INT IDENTITY(1,1) NOT NULL] what is the use of IDENTITY data type

  • Identity is not the data type, INT is.

    The identity property specifies that this column is autopopulated by an integer, starting at 1 and adding 1 for each new row.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (7/25/2013)


    Identity is not the data type, INT is.

    The identity property specifies that this column is autopopulated by an integer, starting at 1 and adding 1 for each new row.

    Just to make it clear: columns can be set an Identity if it's constrained to be nonnullable and it is one of the following datatypes:

    int, bigint, smallint, tinyint, decimal or numeric with scale of 0

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply