alter table tablename add  CONSTRAINT PK_xxx PRIMARY KEY  NONCLUSTERED ( Fieldname)
alter table tablename drop  CONSTRAINT PK_xxx

解决方案 »

  1.   

    --------------删除主键------------
    alter table alumn drop CONSTRAINT pk_name
    ALTER TABLE 表 DROP COLUMN 编号
      

  2.   

    如果不知道主键名,只知道主键列:-----------------删除主键列--------------
    declare @a varchar(20)
    select @a=c.name from syscolumns a,sysconstraints b,sysobjects c where a.id=object_id('表名') and a.name='主鍵列名' and a.id=b.id and b.constid=c.id and c.name like 'PK%'
    exec('alter table 表名 drop constraint '+@a)