【问题标题】:How to alter column with primary key and identity [duplicate]如何使用主键和标识更改列[重复]
【发布时间】:2013-06-29 22:14:16
【问题描述】:

如何更改现有表中的列的主键和标识。我尝试了以下查询,但显示Incorrect syntax near the keyword 'identity'.

alter table IAM_Software_Licence_Master
alter column SoftwareLicId int  identity(1,1) primary key

我怎样才能做到这一点..

【问题讨论】:

  • 您无法更改列。根据欺骗链接删除并重新创建
  • 现有表的CREATE TABLE 定义是什么?

标签: sql-server sql-server-2012


【解决方案1】:

由于我不知道表结构或是否将其用作外键,因此很难说最终更改此设置有什么问题。但是下面的链接应该为您提供所需的一切: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/04d69ee6-d4f5-4f8f-a115-d89f7bcbc032/how-to-alter-column-to-identity11

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-20
    • 2018-08-30
    • 1970-01-01
    • 2012-07-28
    • 2020-09-01
    • 1970-01-01
    • 2015-01-26
    相关资源
    最近更新 更多