Blog Of Sem: Büyük tablodan sqlden verileri silme

Büyük tablodan sqlden verileri silme

bu etkili alttakiler deil fazla
declare @counter int
declare @numOfRecords int
declare @batchsize int

set @numOfRecords = (SELECT COUNT(*) AS NumberOfRecords  FROM  Erp_InventoryReceiptItem  with(nolock)  where ParentItemId is not null)
set @counter = 0
set @batchsize = 2500

set rowcount @batchsize
while @counter < (@numOfRecords/@batchsize) +1
begin
set @counter = @counter + 1
Update Erp_InventoryReceiptItem set ParentItemId = null;
end
set rowcount 0
----------------------------------------------
alttakiler:

USE LIVE_UNIMAR_YENI
GO

-- Set to simple mode
ALTER DATABASE LIVE_UNIMAR_YENI SET RECOVERY SIMPLE;
GO

-- Get count of records
SELECT COUNT(*) AS Total FROM Erp_InventoryReceiptItem
GO

-- Delete in batches
DECLARE @VAR_ROWS INT = 1;
WHILE (@VAR_ROWS > 0)
BEGIN
    DELETE TOP (100000) FROM Erp_InventoryReceiptItem
    SET @VAR_ROWS = @@ROWCOUNT;
    CHECKPOINT;
END;
GO

-- Set to full mode
ALTER DATABASE LIVE_UNIMAR_YENI SET RECOVERY FULL;
GO