How do I add auto_increment to a column in SQL Server 2008

前端 未结 5 798
走了就别回头了
走了就别回头了 2021-01-12 21:10

I am using SQL Server 2008 and a primary key of a database table I am using is not an IDENTITY column (not sure why). I need to change that.

I am in SQ

5条回答
  •  无人共我
    2021-01-12 21:30

    You need to expand the "Identity Specification" node to change it via the (Is Identity) property.

    This will rebuild the table so you might also need to go into Tools -> Options -> Designers -> Prevent saving changes that require table re-creation.

    This can be an extremely time consuming operation on large tables as well as entailing a lot of logging and locking. To perform this operation on a large table see my answer here.

提交回复
热议问题