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.
| Author |
Topic |
|
coolerbob
Aged Yak Warrior
841 Posts |
Posted - 2005-04-19 : 03:35:08
|
| I have a query similar to this:SET ROWCOUNT 10000DECLARE @intRowCount intSELECT @intRowCount=1WHILE @intRowCount > 0BEGININSERT INTO DestinationTableSELECT *FROM SourceTableWHERE NOT EXISTS (SELECT * FROM DestinationTable WHERE DestIDColumn = SourceIDColumn)SELECT @intRowCount = @@ROWCOUNTENDthis took 4 minutes for 210 000 rowsI tried to improve the performance by adding transactions:SET ROWCOUNT 10000DECLARE @intRowCount intSELECT @intRowCount=1WHILE @intRowCount > 0BEGINBEGIN TRANSACTIONINSERT INTO DestinationTableSELECT *FROM SourceTableWHERE NOT EXISTS (SELECT * FROM DestinationTable WHERE DestIDColumn = SourceIDColumn)SELECT @intRowCount = @@ROWCOUNTCOMMITENDbut this was still running 14 hours later!Is there a way to accomplish the same result (batch inserting) in a statement without the performance cost of"WHERE NOT EXISTS (SELECT * FROM DestinationTable WHERE DestIDColumn = SourceIDColumn)"? |
|
|
|
|
|