Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT Performance

Status
Not open for further replies.

StoneDeCroze

Programmer
Feb 11, 2002
36
0
0
GB
Hi All,

I have two tables and I want to insert data from them into a third table.
Question:
Am I better to write two inserts statements e.g.

INSERT INTO table3 (field1, field2) SELECT field1, field2 FROM table1

and

INSERT INTO table3 (field1, field2) SELECT field1, field2 FROM table2

OR one insert statement

INSERT INTO table3 (field1, field2)
SELECT field1, field2 FROM table1
UNION ALL
SELECT field1, field2 FROM table2

Are two inserts better or worse than one insert and a UNION ALL.

Cheers
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top