有没有办法可以遍历我的SQL Server表并写出一个文本文件删除文件需要多长时间才能说每10,000行?
DELETE FROM ORDERS o
INNER JOIN CUSTOMER c
ON o.CustomerID = c.CustomerID
WHERE ActiveDt < '03/03/2001'
DELETE FROM CUSTOMER
WHERE ActiveDt < '03/03/2001'
答案 0 :(得分:0)
DECLARE @TS AS datetime;
DECLARE @CNT int;
lab:
SET @TS = getdate();
;WITH CTE AS (SELECT TOP 10000 * from CustTable)
DELETE CTE ;
SET @CNT = @@rowcount;
PRINT DATEDIFF(millisecond, @TS, getdate()); --write away somewhere if required
If @CNT > 0
GOTO lab
您可以使用spWriteStringToFile将数据推送到文本文件