BEGIN TRANSACTION
BEGIN TRY
;WITH CTE_TQUOTEWO
AS
(
SELECT WORKID,QUOTE_NO
FROM ABC_TQUOTEWO WITH(INDEX(PK_TQUOTEWO_ID))
WHERE TQUOTEWO_ID != ''
)
DELETE CA
FROM CTE_TQUOTEWO CA
JOIN I_ABC_TQUOTEWO AT WITH(INDEX(PK_ITQUOTEWO_ID))
ON AT.WORKID = CA.WORKID
AND AT.QUOTE_NO = CA.QUOTE_NO
AND AT.TQUOTEWO_ID != '';
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
我有一个包含数百万条记录的表,并且没有定义索引,但仍需要很长时间才能执行。任何人都可以建议更快地执行删除操作吗? 使用sql server ...
答案 0 :(得分:2)
答案 1 :(得分:0)
如果您不需要记录,可以使用Truncate。
答案 2 :(得分:0)
TRUNCATE TABLE TableName;
截断应该比
更快DELETE FROM TableName;