sqlserver对字段出现NULL值的处理

前端之家收集整理的这篇文章主要介绍了sqlserver对字段出现NULL值的处理前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="68577" class="copybut" id="copybut68577" onclick="doCopy('code68577')"> 代码如下:

<div class="codebody" id="code68577">
-判断某些字段是否为空
--case
select case when '字段名' is null then '\N' else convert(varchar(20),'字段名') end as 'NewName'
select case when null is null then '\N' else convert(varchar(20),null) end as 'NewName' --sql Server 2005:coalesce
select coalesce('字符串类型字段','\N') as 'NewName'
select coalesce(convert(varchar(20),'非字符串类型字段'),null),'\N') as 'NewName' --coalesce,返回其参数中的第一个非空表达式
select Coalesce(null,null,1,2,null)union
select Coalesce(null,11,12,13,null)union
select Coalesce(111,112,113,114,null)

原文链接:https://www.f2er.com/mssql/64046.html

猜你在找的MsSQL相关文章