Tim Chapman discusses your iteration choices in SQL Server 2008 and explains why determining which option performs better depends on the situation. In a previous TechRepublic column about SQL Server ...
ALTER TABLE agent_tasks ADD COLUMN IF NOT EXISTS loop_count integer NOT NULL DEFAULT 0; ALTER TABLE agent_tasks ADD COLUMN IF NOT EXISTS reflect_log jsonb NOT NULL DEFAULT '[]'::jsonb; -- [{round, ...
-- Scenario 10: a WHILE loop that processes rows in batches and logs progress. -- Expected: dbo.FactSales.IsDeleted written in a loop; @Rows <- @@ROWCOUNT; dbo.LoadLog.RowsAffected <- @Rows.