Table1
--------------------------------------------------------
a(varchar) | b(varchar) | c(varchar) | d(float)
---------------------------------------------------------
has value | has value | null | has value
---------------------------------------------------------
There are arround 13 million records in this table.
The combination of a and b is unique.
Table2
------------------------------------------------
a(varchar) | b(varchar) | c(float)
------------------------------------------------
has value | has value | has value
-------------------------------------------------
There are arround 13 million records in this table.
The combination of a and b is unique.
I have a simple procedure to put the c value of table2 into c value of table1.
The procedure looks like this
------------------------------------------------------------
create procedure my_procedure as
-----------------------------------------------------------------------------------------------------
I have created index of type clustered the preformance of my procedure should increase. But still i am afraid to run the procedure as it took 17 hours to update 2000 matching records. Let me explain the problem very clearly.
There are 2 tables:
I have created Clustered index on the column a of both tables(note: column a has more repeating values)
I have to transfer the value in column d in Table2 to column c of Table1
--------------------------------------------------------
a(varchar) | b(varchar) | c(varchar) | d(float)
---------------------------------------------------------
has value | has value | null | has value
---------------------------------------------------------
There are arround 13 million records in this table.
The combination of a and b is unique.
Table2
------------------------------------------------
a(varchar) | b(varchar) | c(float)
------------------------------------------------
has value | has value | has value
-------------------------------------------------
There are arround 13 million records in this table.
The combination of a and b is unique.
I have a simple procedure to put the c value of table2 into c value of table1.
The procedure looks like this
------------------------------------------------------------
create procedure my_procedure as
begin
declare @a nvarchar(255),@ b nvarchar(255)
declare @c nvarchar(255)
declare c1 cursor dynamic
for select a,b,c from table2
open c1
fetch next from c1 into @a,@b,@c
deallocate c1
end declare @a nvarchar(255),@ b nvarchar(255)
declare @c nvarchar(255)
declare c1 cursor dynamic
for select a,b,c from table2
open c1
fetch next from c1 into @a,@b,@c
while(@@fetch_s tatus = 0)
begin
update table1
set c = @c
where a = @a and
b = @b
fetch next from c1 into @a,@b,@c
if @@error <> 0
print 'exception 1 ' + @@error
end
close c1 begin
update table1
set c = @c
where a = @a and
b = @b
fetch next from c1 into @a,@b,@c
if @@error <> 0
print 'exception 1 ' + @@error
end
deallocate c1
-----------------------------------------------------------------------------------------------------
I have created index of type clustered the preformance of my procedure should increase. But still i am afraid to run the procedure as it took 17 hours to update 2000 matching records. Let me explain the problem very clearly.
There are 2 tables:
I have created Clustered index on the column a of both tables(note: column a has more repeating values)
I have to transfer the value in column d in Table2 to column c of Table1
Comment