SQL Server how to drop identity from a column

前端 未结 3 1733
予麋鹿
予麋鹿 2020-12-08 01:18

Is there an easy way to remove an identity from a table in SQL Server 2005?

When I use Management Studio, it generates a script that creates a mirror table without

3条回答
  •  渐次进展
    2020-12-08 01:54

    I don't believe you can directly drop the IDENTITY part of the column. Your best bet is probably to:

    • add another non-identity column to the table
    • copy the identity values to that column
    • drop the original identity column
    • rename the new column to replace the original column

    If the identity column is part of a key or other constraint, you will need to drop those constraints and re-create them after the above operations are complete.

提交回复
热议问题