Set start value for column with autoincrement

后端 未结 4 1626
灰色年华
灰色年华 2020-11-28 23:47

I have a table Orders with the following fields:

Id | SubTotal | Tax | Shipping | DateCreated

The Id c

4条回答
  •  盖世英雄少女心
    2020-11-28 23:58

    You need to set the Identity seed to that value:

    CREATE TABLE orders
    (
     id int IDENTITY(9586,1)
    )
    

    To alter an existing table:

    ALTER TABLE orders ALTER COLUMN Id INT IDENTITY (9586, 1);
    

    More info on CREATE TABLE (Transact-SQL) IDENTITY (Property)

提交回复
热议问题