Saturday , August 18 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

sql server backup script

Backup all databases in SQL Instance with one script

Backup: A copy of SQL Server data that can be used to restore and recover the …