我是靠谱客的博主 结实歌曲,这篇文章主要介绍sqlserver对字段出现NULL值的处理,现在分享给大家,希望可以做个参考。

复制代码 代码如下:

-判断某些字段是否为空
--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),'非字符串类型字段'),'\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)

最后

以上就是结实歌曲最近收集整理的关于sqlserver对字段出现NULL值的处理的全部内容,更多相关sqlserver对字段出现NULL值内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(215)

评论列表共有 0 条评论

立即
投稿
返回
顶部