为什么选择'abc'+ null = null [英] Why select 'abc' + null =null

查看:141
本文介绍了为什么选择'abc'+ null = null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我想知道为什么选择``abc''+ null会导致null.

谢谢,
Jagjot

Hello Friends,

I would like to know that why select ''abc'' + null results in null.

Thanks,
Jagjot

推荐答案

这是因为 CONCAT_NULL_YIELDS_NULL [ ^ ]一个儿子.您可以在查询中将其关闭,结果将受到影响.
虽然不建议您将其关闭,但应谨慎使用.
This is because CONCAT_NULL_YIELDS_NULL [^] is by default set as ON. YOu can turn it off in your query and the result will be affected.
Although, turning it off is not recommended and should be used carefully.


您可以将其关闭.

SET CONCAT_NULL_YIELDS_NULL {开|关闭}

http://msdn.microsoft.com/en-us/library/ms176056.aspx [ ^ ]
You can switch it off.

SET CONCAT_NULL_YIELDS_NULL { ON | OFF }

http://msdn.microsoft.com/en-us/library/ms176056.aspx[^]


当连接null值时,concat null产生sp_dboption的null设置,或者SET CONCAT_NULL_YIELDS_NULL确定一个表达式为NULL时的行为.concat null产生null或SET CONCAT_NULL_YIELDS_NULL启用时,字符串" NULL返回NULL.如果concat null产生null或禁用SET CONCAT_NULL_YIELDS_NULL,则结果为字符串"."

这是从 http://msdn.microsoft.com/en-us/library/aa276862(v = sql.80).aspx [ ^ ].
"When you concatenate null values, either the concat null yields null setting of sp_dboption or SET CONCAT_NULL_YIELDS_NULL determines the behavior when one expression is NULL. With either concat null yields null or SET CONCAT_NULL_YIELDS_NULL enabled ON, ''string'' + NULL returns NULL. If either concat null yields null or SET CONCAT_NULL_YIELDS_NULL is disabled, the result is ''string''."

This was from http://msdn.microsoft.com/en-us/library/aa276862(v=sql.80).aspx[^].


这篇关于为什么选择'abc'+ null = null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆