aid,aname这两列中,至少有一列是允许null值的,而设置为主键的列是不允许的

解决方案 »

  1.   

    --将列修改不不允许null的,再创建主键就没问题了.alter table tb_author alter column aid int not null
    alter table tb_author alter column aname varchar(10) not null
    go
    alter table tb_author add constraint PK_tb_author primary key(aid,aname)
      

  2.   

    --或者你在创建表的时候就指定  not null
    create table tb_author(aid int not null,aname varchar(10) not null)
    alter table tb_author add constraint PK_tb_author primary key(aid,aname)