日期:2014-05-18  浏览次数:20465 次

请问这个设计如何实现?
我想实现这样的设计
      字段1   字段2   字段3   字段4
值     A             1           2             3
        A             1           2             3
是允许的

      字段1     字段2   字段3     字段4
        A               1             2         3
        A               1             2         4
是不允许的

既当表中两H行记录的字段1内容相同时,字段2、3、4也必须是相同的,请问该如何定义呢?

------解决方案--------------------
你表中存一些完全相同的重复记录,意义?

------解决方案--------------------
定义触发器吧.
create trigger tr_check on table
for insert,update
as
begin
if exists (select * from table t ,inserted i where t.字段1=i.字段1 and t.字段2=i.字段2 and t.字段3=i.字段3 and t.字段4=i.字段4 )
raiserror ( '违反了.. ',16,1)

end


end