I have the following structre table
Table1 Table2 Table3
--------------------------------
sId sId sId
name x y
x1 x2 x3
I want to delete all records from table1 that do not have a corresponding record in table3 based on sId, and if sId is present in table2, then do not delete the record from table1.Tech is about 20.15 and 10 million records in table1, table2 and table3 resp . - I did something like this
Delete Top (3000000)
From Table1 A
Left Join Table2 B
on A.Name ='XYZ' and
B.sId = A.sId
Left Join Table3 C
on A.Name = 'XYZ' and
C.sId = A.sId
((I added an index to sId, but not to the name.))
But it takes a long time to delete entries. Is there a better way to delete millions of records? Thanks in advance.
David source
share