create function f_asc(@ss nvarchar(4000))
returns int
as
begin
declare @i int,@r int
select @r=1,@i=1
while @i<=len(@ss)
begin
if ascii(substring(@ss,@i,1))>128
set @r=0
set @i=@i+1
end
return @r
endcreate table tb(s varchar(50) check (dbo.f_asc(s)=1))insert into tb select 'abc'
insert into tb select '123abc'insert into tb select 'abc和def'
--INSERT 语句与 CHECK 约束"CK__tb__s__7AF13DF7"冲突。该冲突发生于数据库"my2",表"dbo.tb", column 's'。
select * from tb