在查询分析器里都是有用的
select * from xxx where yyy=null存储过程里面是没有返回任何数据,因为yyy=后面的值是变量,也许是有值的也许是空值,所以不能用is null

解决方案 »

  1.   

    对于存储过程,SQL Server 使用最初创建存储过程时的 SET ANSI_NULLS 设置值。无论随后何时执行存储过程,SET ANSI_NULLS 的设置都还原为其最初使用的值并生效。当在存储过程内唤醒调用 SET ANSI_NULLS 时,其设置不更改。
      

  2.   

    --try
    create table T(col1 int, col2 int)
    insert T select 1, 1
    insert T select 2, null
    insert T select 3, 3set ansi_nulls off
    go
    create proc pc
    as 
    select * from T where col2 = null
    goset ansi_nulls on
    goexec pc
    go
      

  3.   

    吐血,在帮助里看到这段话,但是没理解,不服老不行了我可以理解为set ansi_nulls off是存储过程结构的一部分吧,已经保存在里面了,如果我建立完成后不set ansi_nulls on的话,是不是一直都可以=null来比较空值?
      

  4.   

    我可以理解为set ansi_nulls off是存储过程结构的一部分吧
    -----------------------------------------------------
    set ansi_nulls off 是默认设置
      

  5.   

    set ansi_nulls off 是默认设置?你搞反了吧,默认是不能直接与空值比较的