那用触发器在insert和update时判断

解决方案 »

  1.   

    alter table 表 add  newfield int identity(1,1)delete 表
    where newfield not in(
     select min(newfield) from 表 group by 除newfield外的所有字段
                         )alter table 表 drop column newfield
      

  2.   

    CREATE TRIGGER 名1 ON 表
    FOR INSERT
    AS
    if exists(select 1 from inserted tem where exists(select 1 from 表 where 列1=tem.列1 and 列2=tem.列2))