Reputation: 971
Supose you have two tables with the exactly the same columns.
Table1:
Name Type AveSls
A 2 20
B 4 10
C 1 15
Table2:
Name Type AveSls
D 2 8
E 3 15
F 1 12
How do i combine the two tables in SQL server 2008 with a SQL satement so that the combined table looks like this:
Table3:
Name Type AveSls
A 2 20
B 4 10
C 1 15
D 2 8
E 3 15
F 1 12
Upvotes: 0
Views: 146
Reputation: 43023
You can simply use UNION ALL
(to get all rows even if they repeat in both tables) or UNION
to get non-repeating rows.
SELECT name,
type,
avesls
FROM table1
UNION ALL
SELECT name,
type,
avesls
FROM table2
Read more about UNION
on MSDN.
Upvotes: 5