SET ANSI_NULLS OFF似乎在TSQL中给出不同的结果,具体取决于您是在比较表中的字段还是值.任何人都可以帮助我理解为什么我的最后两个查询没有结果?我不是在寻找解决方案,只是一个解释.
select 1 as 'Col' into #a
select NULL as 'Col' into #b
--This query gives results, as expected.
SET ANSI_NULLS OFF
select * from #b
where NULL = Col
--This query gives results, as expected.
SET ANSI_NULLS OFF
select * from #a
where NULL != Col
--This workaround gives results, too.
select * from #a a, #b b
where isnull(a.Col, '') != isnull(b.Col, '')
--This query gives no results, why?
SET ANSI_NULLS OFF
select * from …Run Code Online (Sandbox Code Playgroud)