SqlServer series notes-- Joint query UNIONSqlServer series notes
Basic principle: each result set must have the same number of columns; the columns of each result set must be of compatible types.
SELECT FName FROM T_Employee UNION
SELECT FName FROM T_TempEmployee
one
SELECT FName FROM T_Employee
UNION ALL
SELECT FName FROM T_TempEmployee
Note: UNION merges two query result sets and merges completely duplicate rows into one. Union is inefficient because it needs to scan duplicate values, so if you are not sure you want to merge duplicate rows, use UNION ALL