Adding an identity to an existing column

后端 未结 19 2054
温柔的废话
温柔的废话 2020-11-21 13:16

I need to change the primary key of a table to an identity column, and there\'s already a number of rows in table.

I\'ve got a script to clean up the IDs to ensure

19条回答
  •  悲&欢浪女
    2020-11-21 13:59

    To modify the identity properties for a column:

    • In Server Explorer, right-click the table with identity properties you want to modify and click Open Table Definition. The table opens in Table Designer.
    • Clear the Allow nulls check box for the column you want to change.
    • In the Column Properties tab, expand the Identity Specification property.
    • Click the grid cell for the Is Identity child property and choose Yes from the drop-down list.
    • Type a value in the Identity Seed cell. This value will be assigned to the first row in the table. The value 1 will be assigned by default.

    That's it, and it worked for me

提交回复
热议问题