-判斷某些欄位是否為空 --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)
-判斷某些欄位是否為空 --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)