WHILE @Number < = 10 BEGIN IF @NUMBER = 5 GOTO quantrimang; ELSE SET @Total = @Total + @Number; SET @Number = @Number + 1 ; END;
quantrimang PRINT @Total;
GO
In the example using this GOTO statement, we created a label named quantrimang, when the @NUMBER variable reached value 5, the program allowed to jump to the position of the quantrimang label in the function and execute the statement following it. .
on september 24, microsoft announced the release of sql server 2019 community technical preview (ctp) 2.0. it is very suitable for database professionals to keep up with modern technology.
the while loop is used if you want to run a code repeatedly when the given condition returns true. let's find out how to use while in sql server with network administrator.