设置不为NULL,结果有NULL?闹鬼了?

解决方案 »

  1.   

    这么神奇,不应该啊
    竟然设置为 NOT NULL
    还会有NULL同关注
      

  2.   

    create table [tb]
    (
      [id] int identity(1,1),
      [col] varchar(5) not null
    )insert tb select null
    /**
    服务器: 消息 515,级别 16,状态 2,行 1
    无法将 NULL 值插入列 'col',表 'test.dbo.tb';该列不允许空值。INSERT 失败。
    语句已终止。
    **/
     
    insert tb select 'null'
    select * from tb 
    /**
    id          col   
    ----------- ----- 
    1           null(所影响的行数为 1 行)
    **/
    会不会这种情况?
      

  3.   

    实际环境不是这样,我那个字段的类型是 int, 而不是varchar, 所以把 'null' 是无法写入进去的。
    所以这次事情的确让我对SQL SERVER的可靠性有所怀疑,无语 ......