Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Merging 3 tables

Author  Topic 

martind1
Starting Member

28 Posts

Posted - 2012-02-17 : 08:30:20
Hi,

I have 3 tables and a master table. The columns and indexes are identical. When all 3 tables have been populated, I need to merge all 3 into the Master table. But each table has approx 4million rows and 50 columns. Currently the following solution takes ages:


INSERT INTO dbo.MASTERTable
SELECT column1, column2 FROM dbo.Table1


INSERT INTO dbo.MASTERTable
SELECT column1, column2 FROM dbo.Table2


INSERT INTO dbo.MASTERTable
SELECT column1, column2 FROM dbo.Table3


Is there any quicker way to do this?

Thanks in advance :)

--
http://www.tutorial-resource.com - Free Web Development Resources

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-02-17 : 08:37:17
1. You can SSIS to do this out-of-process.
2. You can use Service Broker to have your master table as a central repository.
3. Make the inserts in smaller batches.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -