DECLARE @TrimDate AS datetime = DATEADD(day, -14, CURRENT_TIMESTAMP);
-- This DECLARE assignment sets @@ROWCOUNT to 1
WHILE @@ROWCOUNT > 0
BEGIN;
DELETE TOP(4000) FROM dbo.Logging -- 5,000 is the default lock escalation threshold
WHERE LogDate < @TrimDate;
END;