isnull(Sdept,'IS')的意思是判断Sdept是否为空,若为空则用'IS'代替。
可和后面的='IS'边起来,哪位说说:
isnull(Sdept,'IS')= 'IS '; 
是什么意思?

解决方案 »

  1.   

    isnull(Sdept,'IS')
    ======如果Sdept为null(不是为空),则取值为‘IS’,否则为Sdept.isnull(Sdept,'IS')= 'IS ';
    ===============
    可以理解为一个条件,由具体业务逻辑决定。
      

  2.   

    是不是这样:
        先判断Sdept='IS',若Sdept为null,则让Sdept='IS'
      

  3.   

    我是看了别人发的关于视图的贴子中没有解决的问题,提出此问题
    视图创建语句为:
    create   view   [dbo].[IS_Student] 
    as   
    select   Sno,Sname,Sage 
    from   Student 
    where   isnull(Sdept,'IS')= 'IS ';
      

  4.   


    isnull(Sdept,'IS')= 'IS ';
    =================
    只是逻辑中的一部分,它的上下文呢?
    举个例子,不过不太合理:
    if isnull(Sdept,'IS')= 'IS '
        ---update tb
    else
        ---insert into tb
      

  5.   


    ====
    等价于:
    create   view   [dbo].[IS_Student] 
    as   
    select   Sno,Sname,Sage 
    from   Student 
    where  Sdept is null;
      

  6.   


    这个意思就是说查询出student表中的所有的sdept的值为IS或者为null的所有记录,当为null时就用IS代替,IS当然等于IS了,如果本身的值就为IS,那么也可以查询出来。
      

  7.   

    use test
    go
    if object_id('test.dbo.tb') is not null drop table tb
    -- 创建数据表
    create table tb
    (
    dept char(3),
    id int
    )
    go
    --插入测试数据
    insert into tb select 'IS',101
    union all select null,107
    union all select 'MA',113
    union all select 'IS',118
    union all select 'CS',124
    go
    --代码实现select * from tb/*测试结果dept id
    ---------------
    IS  101
    NULL 107
    MA  113
    IS  118
    CS  124(5 行受影响)
    */select * from tb where isnull(dept,'IS')='IS'/*测试结果dept id
    ---------------
    IS  101
    NULL 107
    IS  118(3 行受影响)
    */select * from tb where dept='IS' or dept is null/*测试结果dept id
    ---------------
    IS  101
    NULL 107
    IS  118(3 行受影响)
    */
      

  8.   

    你 这招博弈 不错。
    http://topic.csdn.net/u/20071114/21/a16793d7-7f32-4aee-b374-0bf44444b733.html?86882
      

  9.   

    你去查查isnull 的用法就明白了。
      

  10.   


    isnull(sdept,'is') = is==> 不就是:sdept is null or sdept = 'is'
      

  11.   

    既然都理解 isnull 什么意思了,还不能理解 isnull(Sdept,'IS')='IS' 什么意思?逻辑缺失
      

  12.   

    我个人的理解是:选出student表中 Sdept为null或'IS'的学生的sno,sname,sage来创建视图
      

  13.   

    最直接的意思 就是 字段值为 null,'IS' 都 满足 这个 where 条件
      

  14.   

    等价于sdept的值为IS或者为null
      

  15.   

    太sb了 还不如直接写is null
      

  16.   

    是不是贴代码的时候错误,大家都没注意到'IS '后面的那个空格,可能是作者认为sqlserver不忽略空格吧 这样还理解的,当然也可以能全角空格
      

  17.   

    isnull(Sdept,'IS')= 'IS ';先判断 Sdept 是否为空,如果为空则把字符串‘IS’附给 Sdept 
    然后再判断 Sdept 的值是否等于‘IS’
      

  18.   


    这是个布尔表达式,而且是出现在where子句如果表达式右侧的常量真的含有一个空格,
    那么这个表达式逻辑上等效于找出Sdept等于'IS '值的记录,
    这时候,null不会被检出,因为null被转换成'IS'了,'IS'不等于'IS '如果那个空格是笔误造成的,表达式事实上是:isnull(Sdept,'IS')= 'IS',
    逻辑上等效于找出Sdept为null值 或者 Sdept等于'IS'值的记录
      

  19.   

    isnull(Sdept,'IS')= 'IS '
    ============
    Sdept = 'IS' or Sdept is null
      

  20.   


    我真烦透了,你们不仔细看题和别人的回复吗?
    都已经说了,视而不见!
    'IS'= 'IS '?????
    注意那个空格!!!
      

  21.   

    一样的,后面带的空格可以省略,其实还是相当于:Sdept = 'IS' or Sdept is null
      

  22.   

    isnull(Sdept,'IS')的意思是判断Sdept是否为空,若为空则用'IS'代替。
    可和后面的='IS'边起来,哪位说说:
    isnull(Sdept,'IS')= 'IS ';  
    是什么意思? 
     
     
    先判断是否为空,若为空则用'IS'代替,否则为Sdept
    再与'IS'比较是否相等在sql server 2000 中 'IS'与'IS '是相等
      

  23.   

    先判断Sdept='IS',若Sdept为null,则让Sdept='IS'
      

  24.   

    应该是条件判断
    等价于:
    (Sdept='IS' or Sdept is null)
      

  25.   


    (sdept=@sdept or ISNULL(@sdept ,'')='')
    意思是:如果@sdept有传值进来,就过滤,否则不过滤。 
      

  26.   

    (Sdept='IS' or Sdept is null)
      

  27.   

    这位大侠 能否把SQL函数 列举一下~~~~~~~
      

  28.   

    ===if Sdept is null
    begin
    end
      

  29.   


    不等价。
    等价于Sdept='IS' Or Sdept Is Null