Ways of Replacing null values in Sql Server with customize value.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 250
1st way using ISNULL:-
Select person_id,IsNull(Middle_Name,'NA') as name from person_master where MIDDLE_NAME is null;

2nd way using Coalesce:-
Select person_id,Coalesce(Middle_name,'NA') as name from person_master where MIDDLE_NAME is null;

3rd way using CASE:-
Select p.person_id,case when p.MIDDLE_NAME is null then 'NA' else p.MIDDLE_NAME end as name from person_master p where p.MIDDLE_NAME is null;

Comments or Responses

Login to post response