什么是tsql!>操作员呢?

时间:2012-08-03 11:34:47

标签: tsql null operators

我想知道这个操作员做了什么,我找不到任何关于它的东西。 很高兴看到一些使用示例。

set ansi_nulls [on | off]
expression !> expression (NULL)

例如:这些查询返回相同的结果(1):

select 1 where 1 !> 1;

select 1 where 1 = 1;

但这些查询没有返回任何内容:

set ansi_nulls off;
select 1 where null !> null;

set ansi_nulls on;
select 1 where null !> null;

1 个答案:

答案 0 :(得分:6)

其陈述“Not greater than”。

例如:

IF 1 !> 2
BEGIN
    PRINT 'foo'
END

此查询将PRINT“foo”,因为1 不大于 2。


1不大于1,因此返回true

1等于1,因此这也将返回true

因此,为什么你的两个陈述都会返回相同的结果。


比较null时不会返回任何内容,因为它们没有值。 (即null != null)。所以声明永远不会是true