--测试正常
create table T1(f1 int,f2 int)
goalter table T1
add CONSTRAINT ChK_F1 CHECK([f1] > [f2])
godrop table T1

解决方案 »

  1.   

    alter table T1  with nocheck
    add CONSTRAINT ChK_F1 CHECK([f1] > [f2])
      

  2.   

    出错的原因是你的表中已经有违反约束的数据,所以你要先处理表中的数据,用下面的语句查询出违反约束的记录,处理后再添加约束select * from T1 where not ([f1] > [f2])
      

  3.   

    因为之前你的表里有数据,且不满足约束...所以会出错....加上with nocheck就行了
      

  4.   

    zjcxc(邹建) 这个没有问题呀!
    create table T1(f1 int,f2 int)
    goalter table T1
    add CONSTRAINT ChK_F1 CHECK([f1] > [f2])
    godrop table T1
      

  5.   

    就alter语句本身没有问题,在sql2000里面。