Tag : joins


Apply vs Join in sql server 3

What is Apply in SQL Server?

In this topic “Apply vs Join”, we will discuss about the APPLY operator and its usage scenarios. Lot of people got confused “where they can use Apply and what is it”. They afraid about the performance and usage scenario also. In this article we are going to remove all these scary images of Apply from your mind.

So let’s start with ABCD of Apply and try to cover some advanced topics.

The primary use of Apply operator in sql server is to invoke a table valued function (TVF) but it can also be used in some other important scenarios. We will discuss the importance of Apply operator in brief in this article and would also compare this with Join operator. Invoking table valued function (TVF) is for what Microsoft introduced Cross Apply and Outer Apply primarily, as per MSDN.

Apply Operator executes for each … More


JOINs in SQL Server 1

What is a join?

Before starting discuss on joins, first we should know what is join?
SQL Server is a RDBMS(Relation database management system), i.e. it has tables which holds rows and columns and relationship between multiple tables using keys. So when we have to get data from more than one table, we use joins to get it. Join in sql is used to combine rows from two or more table based on comparing one or more common fields.

Types of Joins in SQL

INNER JOIN:- Returns all rows when at least one match in both tables.

LEFT JOIN:- Returns all rows from left table and matched rows from right table.

RIGHT JOIN : – Returns all rows from right table and matched rows from left table.

FULL JOIN :- Returns all rows from both tables.… More