约束一个字段不能为空白,而非null

解决方案 »

  1.   

    用check约束.
    check(col<>'')
      

  2.   

    当然可以ALTER TABLE tab
    ADD CONSTRAINT chk_col CHECK (col <> '' );
      

  3.   

    CHECK (col <> ''  
      

  4.   

    create table tb(字段 varchar(2) check 字段<>'')
      

  5.   


    if object_id('tb','U') is not null
       drop table tb
    go
    create table tb
    (
     id int,
     name varchar(10) check(name<>'')
    )
    go
    insert into tb  select 1,''
      

  6.   

    create table t(
    ID nvarchar(10) not null check(ID>'')
    )
      

  7.   


    ALTER TABLE tab
    ADD CONSTRAINT chk_col CHECK (col <> '' );