在SQL Server中处理Null [英] handle Null in sql server

查看:117
本文介绍了在SQL Server中处理Null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL Server中的Concat函数

当我添加具有任何数据类型的null时,它是int,varchar,char,nvarchar,它总是始终返回null值,我的查询是我希望得到的结果不是null值,而不是null,例如

所以我需要一个查询,该查询将返回没有空值的结果

1st-Select Convert(nvarchar(20) , 1) + Null
输出=空

我要求的结果 1

2nd-Select ''A'' + null



我要求的结果应该是 A 而不是Null

Concat Function in SQL Server

When i add null with any data type either it is int , varchar , char , nvarchar , It re return the null values always , my query is that instead of null value i want the result excluding the null values for example

So i need a query which will return the result without null value

1st - Select Convert(nvarchar(20) , 1) + Null
Output = Null

My required result 1

2nd - Select ''A'' + null
Null


My required result should be A instead of Null

推荐答案

看看这些函数: ISNULL [ ^ ]
Have a look at these functions: COALESCE[^] and ISNULL[^]


Use the Concept of the following line

SET CONCAT_NULL_YIELDS_NULL OFF;

Select  query

SET CONCAT_NULL_YIELDS_NULL ON;







________________________________________________________________________________


这篇关于在SQL Server中处理Null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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