相关疑难解决方法(0)

ANSI_NULLS如何在TSQL中工作?

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)

t-sql null sql-server-2008

4
推荐指数
1
解决办法
2776
查看次数

标签 统计

null ×1

sql-server-2008 ×1

t-sql ×1