Last active
November 29, 2022 17:07
-
-
Save nikanos/159340ff4102599c34c19dd8339195a2 to your computer and use it in GitHub Desktop.
SQL Server TSQL Loop example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @cnt INT = 0; | |
WHILE @cnt < 10 | |
BEGIN | |
PRINT 'Doing Something in loop #' + Convert(VARCHAR(10),@cnt); | |
--Use RAISEERROR to flush PRINT buffer | |
RAISERROR(N'', --message | |
0, --severity | |
1) --state | |
WITH NOWAIT; | |
WAITFOR DELAY '00:00:01'; | |
SET @cnt = @cnt + 1; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment