某表中某字段
如何禁止其写入带有script和js的字符串
例如该字段可以写入java
但是javascript就不能写入
aaajs也不能写入

解决方案 »

  1.   

    触发器
    create tirgger insert_tab 
    on tablename
    for insert
    delect * from inserted where 字段 like'%script%' or 字段 like'%js%'
      

  2.   

    alter table table WITH NOCHECK
    add constraint test check (charindex('js',字段)=0 )
    alter table table WITH NOCHECK
    add constraint test1 check (charindex('js',字段)=0 )
      

  3.   

    上面错了
    alter table table WITH NOCHECK
    add constraint test check (charindex('script',字段)=0 )
    alter table table WITH NOCHECK
    add constraint test1 check (charindex('js',字段)=0 )
      

  4.   

    alter table table WITH NOCHECK
    add constraint test check (charindex('js',字段)=0 and charindex('script',字段)=0 )