How to implement a do-while loop in tsql How to implement a do-while loop in tsql sql-server sql-server

How to implement a do-while loop in tsql


This is effectively a Do-While loop:

WHILE (1=1)  BEGIN  -- Do stuff...  IF (some_condition is true)     BREAK;  END

But as @Joel Coehoorn noted, always try to use a set based approach first. I would only resort to a loop if I can't think of a way to solve using set operations.