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.
I have two tables Student and Employee both table columns and data type are same.
select Name,Mobile,address1 from Student
select Name,Mobile,address1 from employee
Show above student and employee both tables have same record Rajeev which is highlighted.
Select Name,Mobile,address1 from Student
Union ALL Select Name,Mobile,address1 from employee
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.