alter table MemberDetails
add constraint member_pk
primary key (MemberId);
提示错误:
消息 1505,级别 16,状态 1,第 1 行
The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.MemberDetails' and the index name 'member_pk'. The duplicate key value is (7).
消息 1750,级别 16,状态 0,第 1 行
Could not create constraint. See previous errors.
The statement has been terminated.
整个数据库中的表我都检查过,没创建什么index name 'member_pk',表MemberDetails里也没创建主键,怎么会提示这个错误啊?是哪里的问题。我用的是 win7 + sql server 2008.

解决方案 »

  1.   

    select name from sys.objects where name='member_pk'  ---看是不是能找到
      

  2.   

    alter table MemberDetails
    add constraint memberDetails_pk
    primary key (MemberId);
    提示有重名,直接改个名字就行了
      

  3.   

     duplicate key ..
    MemberId列里有重复的值吧
      

  4.   


    The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.MemberDetails' and the index name 'member_pk'. The duplicate key value is (7).额,英语太烂了,创建唯一索引失败,因为用重复值7查看一下
      

  5.   

    duplicate key ?MemberId有重复值.