您现在的位置是:网站首页> 编程资料编程资料
sqlserver对字段出现NULL值的处理_MsSql_
2023-05-26
831人已围观
简介 sqlserver对字段出现NULL值的处理_MsSql_
复制代码 代码如下:
-判断某些字段是否为空
--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)
您可能感兴趣的文章:
相关内容
- mssql数据库中的表、字段sql语句_MsSql_
- SQL Server的通用分页存储过程 未使用游标,速度更快!_MsSql_
- 一段压缩MS SQLServer日志的语句_MsSql_
- Sql function 多行中的列合并为一行一列的方法_MsSql_
- sqlserver 临时表的用法_MsSql_
- sqlserver中更改数据库所属为dbo的方法_MsSql_
- SQLServer更改sa用户名的方法_MsSql_
- 利用脚本自动安装SQLServer的实现步骤分析_MsSql_
- 一个基于ROW_NUMBER()的通用分页存储过程代码_MsSql_
- MSSQL 将截断字符串或二进制数据问题的解决方法_MsSql_