Tuesday , June 19 2018
Home / DataBase / SQL SERVER / Set Operators in Sql Server (one by one)

Set Operators in Sql Server (one by one)

Set Operators in Sql Server (one by one):

SQL server provides the following set operators which combines results from two or more Queries into a single result set. Those are:
1.Union
2.union All
3.Intersect
4.Except
To combine the results of two queries we need to follow the below basic rules
–>The number and the order of the columns must be same in all queries.
–>The datatypes must be compatible.

Sample Tables:

Table 1:EMPLOYEE

Table 2: DEPARTMENT

1.Union:-
Combine the results of two or more queries into a single result set, that includes all the rows that belong to all queries in the union eliminating duplicates , mean time it arranges output data in ascending order.

 

2.union All:-
Same as union but duplicates will not be eliminated.

3.Intersect:-
Returns any distant values that are returned by both the queries on the left and right sides of intersect operand

4.Except:-
Returns any distant values from the left query that are not found on the right query.

 

Print Friendly, PDF & Email

Give us your valuable feedback

comments

About Samba

Check Also

Find all rows count and columns count in single database in sql server

In General for any database it contains lot of tables, if we want to find …

%d bloggers like this: