--删除
alter table 你的表 drop constraint 主键名
go
--修改
ALTER TABLE 你的表 ALTER COLUMN 列名 你的类型
go
--增加
alter table 你的表 add constraint 主键名 primary key (列名)
go
alter table 你的表 drop constraint 主键名
go
--修改
ALTER TABLE 你的表 ALTER COLUMN 列名 你的类型
go
--增加
alter table 你的表 add constraint 主键名 primary key (列名)
go
alter table a add primary key (要设置为主键的列)
use database_name--查看表上主键约束的名字exec sp_helpconstraint table_name---删除表上存在的主键约束drop constraint constraint_name---做完你需要做的工作后---再次修改表,将主键约束添加上alter table table_name
add primary key(column_name)--完成
create table a (bb varchar(10) not null,cc money)alter table a add primary key (bb)select @pk=name from sysobjects where xtype='PK' and parent_obj=object_id('a')
' 上面的a你的表名字exec ('alter table a drop CONSTRAINT '+@pk)这样应该可以吧。