We all know use of joins in SQL Server where we can merge two(or) more table information into one set of data based some predefined conditions.
In this article, we will learn how to joins two tables and replace
null values with predefined text.
Working with inner join, Left Outer Join and Right Outer
know use of joins in SQL Server where we can merge two(or) more table(s)
information into one set of data based on some
Apart from this, we will
learn how to replace null values with custom message when required.
tables with data as shown below, where EmployeeID is P_K(Primary Key) in
EmployeDetails and F_K(Foreign Key) in EmployeeSalary table.
to extract complete information of employee details from EmployeeDetaila and
EmployeSalary tables using SQL joins.
from EmployeDetails RIGHT OUTER join
EmployeeSalary on EmployeDetails.EmployeId=EmployeeSalary.EmployeId
Output is as shown below:
is a requirement to replace NULL values with predefined text we can achieve
this using below query.
EmployeeSalary.EmployeId,ISNULL(EmployeDetails.FirstName,'NoDetails') as FirstName ,ISNULL(EmployeDetails.LastName,'NoDetails') as LastName,ISNULL(EmployeDetails.EmailID,'NoDetails') as EmailID
EmployeDetails RIGHT OUTER
join EmployeeSalary on
OutPut is as shown below:
SQL functions can be used for many tasks and in this article we looked into one of the function ISNULL