--写一个函数
create function chks(@f1 varchar(10))
returns bit
as
begin
   if (select count(*) from t1 where f1=@f1)>3
   return 1
return 0
end
--建表
create table t1(id int identity(1,1),
                f1 varchar(10) 
                constraint aa check(dbo.chks(f1)=0))