我有一个包含3列数据类型INT,Varchar(x)和Image的大型表。它包含190万条记录,我需要删除特定的180万条记录。我尝试过以下代码,但它本身需要2.5天。它在INT列上有1个主键。
SELECT D.Column_A INTO #TEMP
FROM Large_Table D
JOIN Table_C C ON D.Columm_A = C.Column_X
JOIN Table_B B ON C.Column_Y= B.Column_Z
JOIN Table_A A ON A.Column_W= B.Column_Q
WHERE LEFT(A.Column_T,3) = 'abcd'
SET ROWCOUNT 50000 RECORDS_DELS :
DELETE A
FROM Large_Table A
JOIN #TEMP B ON A.Column_A = B.Column_A IF @@ROWCOUNT > 0 GOTO RECORDS_DELS
SET ROWCOUNT 0