Here we will explain how to use  UNION ALL command in SQL or what is  UNION ALL command in SQL Server or how to combine multiple tables in a single result set with example.



The UNION ALL command is used to combine the result set from two or more tables, when using the UNION ALL command all selected columns need to be of the same data type.  UNION ALL to select all duplicate values.

For Example:

I have two tables Student and Employee both table columns and data type are same.

Student Table

select Name,Mobile,address1 from Student


Union ALL in SQL Server.

Employee Table

select Name,Mobile,address1 from employee


Union ALL in SQL Server.

Show above student and employee both tables have same record Rajeev which is highlighted.

Union ALL 

Select Name,Mobile,address1 from Student 
Union ALL Select Name,Mobile,address1 from employee


Union ALL in SQL Server.

Shows above example using with Union ALL command combine both table records with including duplicate data. Rajeev has a record in both tables but when we use Union All command Rajeev record show twice.

I hope this will help for you.


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like