Reference: SQL Server
I have a stored procedure with a while
loop in it and I want some messages to be printed after every 500 loops.
So, I've written -
CREATE spxxx
AS
BEGIN
BEGIN TRAN
DECLARE @counter = 0;
WHILE <somecondition>
SET @counter = @counter + 1;
IF @counter % 50 = 0
BEGIN
PRINT @counter;
END
END
COMMIT TRAN
END -- End spxxx
But it prints all the messages once the proc ends. I want it to print the messages while its running.