Suppose we want to concatenate first_name,middle_name,last_name but these columns also contains null values like:
- select first_name,middle_name,last_name, father_name,emergency_contact_no from sis_student_details
And we want a output like this:
Then we rewrite the query like this:
- select (first_name +ISNULL(middle_name, ' ')+ISNULL(last_name,'')) as Name,
- father_name as [Father Name],emergency_contact_no as[Contact No.]
- from sis_student_details
This query will concatenate null values with string.