Autonumbering for a column

  • Hi,

    I want to get auto numbers for a one of the column in the table. How can I get this.

    Previously, the database in MS Access. So in MS Access we have the datatype AUTONUMBER, it automatically generates the integer number to the rows. We are migrating the database from MS access to SQL Server 2005.

    I want the same thing to be there in SQL Server also.

    Please let me know if we can do this in SQL Server 2005.

    Thanks in Advance,

    Venki.

    Thank You

  • Use IDENTITY property.

  • You might also want to investigate the SQL Server Migration Assistant, which is available free from the Microsoft website. Investigate ALL the options before migration, but it makes a LOT of things MUCH MUCH EASIER !!! In this specific case, that's handled automatically.

    Steve

    (aka smunson)

    :):):)

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • venki (11/12/2008)


    Hi,

    I want to get auto numbers for a one of the column in the table. How can I get this.

    Previously, the database in MS Access. So in MS Access we have the datatype AUTONUMBER, it automatically generates the integer number to the rows. We are migrating the database from MS access to SQL Server 2005.

    I want the same thing to be there in SQL Server also.

    Please let me know if we can do this in SQL Server 2005.

    Thanks in Advance,

    Venki.

    You would create your table like this

    CREATE TABLE [dbo].[Sample](

    [SampleID] [bigint] IDENTITY(1,1) NOT NULL,

    [Name] [varchar](50) NULL

    ) ON [PRIMARY]

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

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