约束的难题,如何创建一个只许输入中文字符的约束?中文字符那么多,不可能向数字或者字母那样[0-9][a-z]来搞啊

解决方案 »

  1.   

    check(co1 not like '%[^吖-座]%')
      

  2.   

    用nchar来判断,汉字应该有个范围吧
      

  3.   

    create table tbl(
       col nvarchar(50) constraint CKC_tbl_col check (not like '%[^吖-座]%')
    )是这样用吗?
      

  4.   

    CREATE TABLE [表名] (
    [ID] [int] NOT NULL ,
    [字段名] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    CONSTRAINT [PK_表名] PRIMARY KEY  CLUSTERED 
    (
    [ID]
    )  ON [PRIMARY] ,
    CONSTRAINT [CK_表名] CHECK (not([字段名] like '%[^吖-座]%'))
    ) ON [PRIMARY]
    GO
      

  5.   

    cuixiping(无心) ( ) 信誉:100    Blog   加为好友  2007-04-18 13:51:23  得分: 0  
     
     
       create table tbl(
       col nvarchar(50) constraint CKC_tbl_col check (not like '%[^吖-座]%')
    )是这样用吗?
      
     
    是这样用
      

  6.   

    create table tbl(
       col nvarchar(50) constraint CKC_tbl_col check (col not like '%[^吖-座]%')
    )试了下,NOT LIKE 前面要加上列名
      

  7.   

    是的需要加列名
    没有列名语法是不正确的
    check(co1 not like '%[^吖-座]%')--偶上面不是有例子