消息 2627,级别 14,状态 1,第 2 行
违反了 UNIQUE KEY 约束 'IX_GblModule'。不能在对象 'dbo.GblModule' 中插入重复键。

语句已终止。

解决方案 »

  1.   

    Create table dbo.GblModule(ID int constraint IX_GblModule unique)
    go
    insert into dbo.GblModule select 1 --OKinsert into dbo.GblModule select 1 --重復出錯
      

  2.   

    GblModule表中有唯一约束或者是主键 先取消掉再插入值
      

  3.   

    --这样可以查出重复值是什么:
    select * from 
    (
    select 插入值列表
    )t where exists(select 1 from gblmodule where 唯一约束所指的列名=t.唯一约束所指的列名)--这样可以避免插入重复值:
    insert into gblmodule select * from
    (
    select 插入值列表
    )t where not exists(select 1 from gblmodule where 唯一约束所指的列名=t.唯一约束所指的列名)