As I said on my previous email one alternative is to use a temporary table.
The following is what I have tried on my machine (SQL 2000, 2GB ram, P4 3.0 with HT with both available to SQL, HD U320 36GB, working at 40MB transfer mode.
Database file size 14GB).
Table
17 fields, char(10) named (COLUMN_x) with the following sample data in all records.
A_36993 A_36993_2 A_36993_3 A_36993_4
A_36993_5 A_36993_6 A_36993_7
x x x x
x x x x
x x
table_1 and table_2 with a index on column_1 (primary key).
Table_3 with no indexes. All with the same columns.
Table_1 is the one with the correct field value, table_2 is the one you are trying to update
Tables with 12 058 440 records each.
Using the method sugested here (update with batch of 35k rows), after 3:30 hours it had only updated 10 million rows.
With the following code
Code:
begin transaction -- new
insert into table_3
select
F1.COLUMN_1,f2.column_2,F1.COLUMN_3,F1.COLUMN_4,F1.COLUMN_5,
F1.COLUMN_6,F1.COLUMN_7,F1.COLUMN_8,F1.COLUMN_9,F1.COLUMN_10,
F1.COLUMN_11,F1.COLUMN_12,F1.COLUMN_13,F1.COLUMN_14,F1.COLUMN_15,
F1.COLUMN_16,F1.COLUMN_17
from table_2 f1
inner join table_1 f2
on f1.column_1 = f2.column_1
commit -- new
truncate table [dbo].[TABLE_2]
drop table [dbo].[TABLE_2]
EXEC sp_rename 'TABLE_3', 'TABLE_2'
ALTER TABLE [dbo].[TABLE_2] WITH NOCHECK ADD
CONSTRAINT [PK_TABLE_2] PRIMARY KEY CLUSTERED
(
[COLUMN_1]
) ON [PRIMARY]
GO
The above code took 40 min to insert all the rows into table_3, and then another 40 min to recreate the index.
I did a further test of inserting into the temp table 41 milion rows, and this took 3:20 minutes to do.
I do not know how this table of mine compares to yours, but if yours have only one index also, and if the record size is smaller than mine (mine is 170 bytes long) then timing (on my machine would be shorter.
This code was run on the server, with local database. If you are doing this over a network then timings will suffer.
If you have a machine comparable to mine then you 35 million records should take around 4-5 hours in total if you do it this way.
this is I think the best you can do.
Regards
Frederico Fonseca
SysSoft Integrated Ltd