日期:2014-05-18 浏览次数:20500 次
create table rai ( id int identity(1,1), pn varchar(10) constraint ck_rai_pn check(patindex('%[^A-Z]%',left(pn,3))=0 or patindex('%[^A-Z]%',left(pn,3))>3) ) insert into rai(pn) values('DR1') /* Msg 547, Level 16, State 0, Line 1 The INSERT statement conflicted with the CHECK constraint "ck_rai_pn". The conflict occurred in database "DBAP", table "dbo.rai", column 'pn'. The statement has been terminated. */ insert into rai(pn) values('DRS') insert into rai(pn) values('DRSP') select * from rai /* id pn ----------- ---------- 2 DRS 3 DRSP (2 row(s) affected) */