x
在Sql Server中,sql语句包含While循环的时候,肯定都或多或少的用到Continue和Break...
下面撸了一个小Demo
Declare @Index Int = 0,@EndIndex Int = 0 While @Index < 100
Begin
Set @EndIndex = @EndIndex + 1
Print 'Continue 之后Index增加...' + Convert(Varchar(1000),@Index)
If @EndIndex > 100
Begin
Print '防止死循环...*************************************************'
Break
End Continue
Set @Index =@Index + 1
End Set @Index = 0 While @Index < 100
Begin
Print 'Continue 之前Index增加...' + Convert(Varchar(1000),@Index)
Set @Index =@Index + 1
Continue
End Set @Index = 0
While @Index < 100
Begin
Print 'Break Index...' + Convert(Varchar(1000),@Index)
Break
End
x