Results 1 to 2 of 2

Thread: Auto Number

  1. #1
    Join Date
    Feb 2003
    Posts
    13

    Auto Number

    Hi,

    How to create an Auto Numbering column/field in MSSQL?


    Thanks in advance

    Xtine

  2. #2
    Join Date
    Sep 2002
    Posts
    169
    Check out IDENTITY

    e.g.

    Create Table MyTable
    (MyTableID INT IDENTITY (5 , 1),
    SomeValue Char(10))

    For this table, the column MyTableID will automatically be assigned a value from SQL. The first value that will be used will be 5 and the next value to be used will 1 more than the last value used.

    You can override the value that SQL Server assigns by using the "SET IDENTITY_INSERT" command.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •