手机
当前位置:查字典教程网 >编程开发 >mssql数据库 >sqlserver对字段出现NULL值的处理
sqlserver对字段出现NULL值的处理
摘要:复制代码代码如下:-判断某些字段是否为空--caseselectcasewhen'字段名'isnullthen'N'elseconvert(...

复制代码 代码如下:

-判断某些字段是否为空

--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数据库迁移的几种方式

sql server中的decimal或者numeric的精度问题

SqlServer 序号列的实现方法

sql server 常用的几个数据类型

查找sqlserver数据库中某一字段在 哪

sql server 2005中使用with实现递归的方法

关于SQLServer2005的学习笔记 XML的处理

sqlserver 游标的简单示例

Sql server 取当天或当月的记录

sqlserver查询某个字段在哪些表中存在

精品推荐
分类导航