join two tables into one big table join two tables into one big table sql sql

join two tables into one big table


May it work to just do:

SELECT col1, col2, col3 INTO Table1FROM Table2 


Start with union all:

select col1, col2, col3 from Table1union allselect col1, col2, col3 from Table2

Your query is trying to deduplicate things, which would slow it down considerably.


I think the best option is to create a view in sql server, this will optimize the performance of the query:

SELECT col1, col2, col3 from Table1union allSELECT col1, col2, col3 from Table2

(As other users said: "union" is used to select distinct values from two tables where as "union all" is used to select all values including duplicates from the tables.)

At the same time I would restrict the number of rows I get from the database if i am writing them for a web and if this is giving me problems, with the new functions of Sql Server 2005 row_number(), with this I would page results.