设置索引,数据库会自动检查唯一性,插入重复记录的时候会报错!

解决方案 »

  1.   

    不一定用触发器,表结构怎样的?
      

  2.   

    在不能重复的字段上创建唯一索引或者主键,让数据库自动处理关键字段重复的数据记录
      

  3.   

    create trigger Trigg_ship_update on ship
    For insert,update
    AS
      if exists(select 1 from inserted where name in (select * from ship))
      begin
        rollback tran
      end
    GO但这样写,好像一句也加不了了
      

  4.   

    我也来请教一下 如果不使用唯一索引或者主键等方式 ?