—方法1:使用isnull替换
select keyId,isnull(info,‘替换null值’) as info from test
—方法2:使用case when 替换
select keyId,case when info is null then ‘替换null值’ else info end as info from test
—方法3:使用coalesce替换相应的值
select keyId , coalesce(info,‘替换null值’) as info from test
— sqlserver 2012``
SQLServer-两种将字段中null值替换为指定值的方法
最新推荐文章于 2024-12-03 15:40:47 发布
本文介绍了三种在SQL中处理NULL值的方法:使用ISNULL、CASE WHEN和COALESCE函数进行值替换,适用于SQL Server 2012及以后版本。
1236

被折叠的 条评论
为什么被折叠?



